Sets the original xml that should be sorted. Builds a dom document of the
xml.

@param originalXml the new original xml
@throws org.jdom.JDOMException the jDOM exception
@throws java.io.IOException    Signals that an I/O exception has occurred.
494983
public void setOriginalXml(final InputStream originalXml) throws JDOMException, IOException {
        SAXBuilder parser = new SAXBuilder();
        originalDocument = parser.build(originalXml);
    }
1183999
public void indexDocument(String docXML) throws Exception {

		String xml = "<add>" + docXML + "</add>";
		DirectXmlRequest xmlreq = new DirectXmlRequest("/update", xml);
		server.request(xmlreq);
	}
728968
public static Document stringToDocument(String xml) {
        try {
            SAXBuilder sax = new SAXBuilder();
            return sax.build(new ByteArrayInputStream(xml.getBytes("UTF-8")));
        } catch (JDOMException e) {
            throw new IllegalArgumentException("Unable to parse xml", e);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unable to parse xml", e);
        }
    }
939143
function createOriginalAttributeXMLData( $originalNode, $originalData )
    {
        $originalNode->setAttribute( 'attribute_id', $originalData['attribute_id'] );
        $originalNode->setAttribute( 'attribute_version', $originalData['attribute_version'] );
        $originalNode->setAttribute( 'attribute_language', $originalData['attribute_language'] );
    }
727730
@Override
    public void onXml(ClientProperties cp)
    {
        hsmd.onInitialize();
        if (cp != null)
        {
            hsmd.setClientProperties(cp);
        }
    }
373626
public static org.w3c.dom.Element convert(org.jdom2.Element node) throws JDOMException
	{
		if (node == null)
			return null; // Convert null->null

		try
		{
			DOMOutputter outputter = new DOMOutputter();

			return outputter.output(node);
		}
		catch (JDOMException e)
		{
			throw new RuntimeException("Error converting JDOM to DOM: " + e.getMessage(), e);
		}
	}
822988
public InputStream getBuilderXML() throws IOException {
        return builderXMLPath == null ?
            Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
            DocFile.createFileForInput(this, builderXMLPath).openInputStream();
    }
239481
public static Document toDocument(String xml) {
		try {

			DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
					.newInstance();
			documentBuilderFactory.setNamespaceAware(true);
			documentBuilderFactory.setIgnoringElementContentWhitespace(true);
			documentBuilderFactory.isIgnoringComments();
			documentBuilderFactory.setCoalescing(true);

			DocumentBuilder documentBuilder = documentBuilderFactory
					.newDocumentBuilder();

			InputSource inputSource = new InputSource();

			inputSource.setCharacterStream(new StringReader(xml));

			Document document = documentBuilder.parse(inputSource);

			removeUnusedNamespaces(document);

			return document;

		} catch (ParserConfigurationException e) {
			throw new RuntimeException(e);
		} catch (SAXException e) {
			throw new RuntimeException(e);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
513960
private String genXML(Set nodes) throws IOException {
        Iterator it = nodes.iterator();
        StringBuffer buf = new StringBuffer(1024);
        buf.append(StateHelper.XML_DOC_START);
        buf.append(getSynchInterval());
        buf.append(StateHelper.XML_DOC_START_END);
        while (it.hasNext()) {
            Node n = (Node) it.next();
            buf.append(StateHelper.XML_NODE_TAG_START);
            buf.append(StateHelper.encodeMACAddress(n.getNodeIdentifier()));
            buf.append(StateHelper.XML_NODE_TAG_AFTER_ID);
            buf.append(n.getClockSequence());
            buf.append(StateHelper.XML_NODE_TAG_AFTER_CSEQ);
            buf.append(n.getLastTimestamp());
            buf.append(StateHelper.XML_NODE_TAG_END);
        }
        buf.append(StateHelper.XML_DOC_END);
        return buf.toString();
    }
1155348
public static void transformDocumentToXml(DomDocument document, StreamResult result) {
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    try {
      Transformer transformer = transformerFactory.newTransformer();
      transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
      transformer.setOutputProperty(OutputKeys.INDENT, "yes");
      transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");

      synchronized(document) {
        transformer.transform(document.getDomSource(), result);
      }
    } catch (TransformerConfigurationException e) {
      throw new ModelIoException("Unable to create a transformer for the model", e);
    } catch (TransformerException e) {
      throw new ModelIoException("Unable to transform model to xml", e);
    }
  }
1070150
protected Object fromXml(String xml, String tagName) throws Exception {
        Document document = XMLUtil.parseXMLFromString(xml);
        NodeList nodeList = document.getElementsByTagName(tagName);
        
        if (nodeList == null || nodeList.getLength() != 1) {
            throw new DOMException(DOMException.NOT_FOUND_ERR, "Top level tag '" + tagName + "' was not found.");
        }
        
        Element element = (Element) nodeList.item(0);
        Class<?> beanClass = getBeanClass(element);
        BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(beanClass);
        doParse(element, builder);
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
        factory.setParentBeanFactory(SpringUtil.getAppContext());
        AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
        factory.registerBeanDefinition(tagName, beanDefinition);
        return factory.getBean(tagName);
    }
197304
public boolean setXML(String strXML)
    {
        Document doc = Util.convertXMLToDOM(strXML);
        return this.setDOM(doc);
    }
291047
private void paintOriginalXML(final String originalXML, final PrintWriter writer) {
		// Replace any CDATA Sections embedded in XML
		String xml = originalXML.replaceAll("<!\\[CDATA\\[", "CDATASTART");
		xml = xml.replaceAll("\\]\\]>", "CDATAFINISH");

		// Paint Output
		writer.println("<div>");
		writer.println("<!-- VALIDATE XML ERROR - START XML -->");
		writer.println("<![CDATA[");
		writer.println(xml);
		writer.println("]]>");
		writer.println("<!-- VALIDATE XML ERROR - END XML -->");
		writer.println("</div>");
	}
1165755
public Api fromXML(String xml) throws Exception {
    // retrieve the JAXB wrapper representation from the xml received
    Api api = Api.fromXML(xml);
    // check whether an error code was sent
    Error error = api.getError();
    // if there is an error - handle it
    if (error != null) {
      // prepare the error message
      String errMsg = "error code=" + error.getCode() + " info:'"
          + error.getInfo() + "'";
      this.handleError(errMsg);
    }
    return api;
  }
437186
public static Element sourceToElement(Source source) throws IOException
   {
      Element retElement = null;

      if (source instanceof StreamSource)
      {
         StreamSource streamSource = (StreamSource)source;

         InputStream ins = streamSource.getInputStream();
         if (ins != null)
         {
            retElement = DOMUtils.parse(ins);
         }
         Reader reader = streamSource.getReader();
         if (reader != null)
         {
            retElement = DOMUtils.parse(new InputSource(reader));
         }
      }
      else if (source instanceof DOMSource)
      {
         DOMSource domSource = (DOMSource)source;
         Node node = domSource.getNode();
         if (node instanceof Element)
         {
            retElement = (Element)node;
         }
         else if (node instanceof Document)
         {
            retElement = ((Document)node).getDocumentElement();
         }
      }
      else if (source instanceof SAXSource)
      {
         // The fact that JAXBSource derives from SAXSource is an implementation detail.
         // Thus in general applications are strongly discouraged from accessing methods defined on SAXSource.
         // The XMLReader object obtained by the getXMLReader method shall be used only for parsing the InputSource object returned by the getInputSource method.

         final boolean hasInputSource = ((SAXSource) source).getInputSource() != null; 
         final boolean hasXMLReader = ((SAXSource) source).getXMLReader() != null;

         if (hasInputSource || hasXMLReader)
         {
            try
            {
               TransformerFactory tf = TransformerFactory.newInstance();
               ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
               Transformer transformer = tf.newTransformer();
               transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
               transformer.setOutputProperty(OutputKeys.METHOD, "xml");
               transformer.transform(source, new StreamResult(baos));
               retElement = DOMUtils.parse(new ByteArrayInputStream(baos.toByteArray()));
            }
            catch (TransformerException ex)
            {
               throw new IOException(ex);
            }
         }
      }
      else
      {
         throw MESSAGES.sourceTypeNotImplemented(source.getClass());
      }

      return retElement;
   }
817458
public void fromXML(String file) throws DocumentException
    {
        SAXReader reader = new SAXReader();
        fromXML(reader.read(new StringReader(file)));
    }
214437
public void readXML(File file) throws IOException, DocumentException {
        project.setCurrentWorkingDirectory(file.getParentFile());
        dataSource = file.getAbsolutePath();
        InputStream in = progessMonitoredInputStream(file, "Loading analysis");
        try {
            readXML(in, file);
        } catch (IOException e) {
            throw newIOException(file, e);
        } catch (DocumentException e) {
            throw new DocumentException("Failing reading " + file, e);
        }
    }