public static void prepareExtensionElement(Document doc, Element command,
			epp_Extension[] extensions) throws epp_XMLException {
		if (extensions != null) {
			Element extension_element = doc.createElement("extension");
			for (int count = 0; count < extensions.length; count++) {
				epp_Extension extension = extensions[count];

				if (extension instanceof epp_SmartExtension) {
					Node extNode = ((LaunchPhaseExtension) extension).toDOM(doc);
					extension_element.appendChild(extNode);
					continue;
				}

				String extension_string = extension.toXML();

				if (extension_string != null && extension_string.length() != 0) {
					try {
						Node extension_node = getExtensionNode(extension_string);
						if (extension_node != null) {
							extension_node = doc.importNode(extension_node,
									true);
							extension_element.appendChild(extension_node);
						} else {
							// if the extension node was null, then it wasn't
							// valid XML or
							// it is just a string (eg "hellothere") and this
							// can be included as a raw string in the extension
							// tag.
							extension_element.appendChild(doc
									.createTextNode(extension_string));
						}
					} catch (Exception xcp) {
						throw new epp_XMLException("error in extension XML ["
								+ xcp.getClass().getName() + "] ["
								+ xcp.getMessage() + "]");
					}
				}
			}
			command.appendChild(extension_element);
		}
	}