2 Replies Latest reply on May 4, 2008 7:58 PM by DrClap

    Using XSLT to enrich an XML document

    807591
      I would like to enrich an XML document. I want to do it by merging the result of a XSLT into it.
      I use the following code:
      javax.xml.transform.Transformer trans = TransformerFactory.newInstance().newTransformer(<xslt doc>);
      Result result = new DOMResult(<the xml doc that i want to enrich>);
      Source xmlSource = new DOMSource(<some other xml doc>);
      trans.transform(xmlSource,result);
      The problem is that I'm getting:
      org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted. 
      at org.apache.xerces.dom.CoreDocumentImpl.insertBefore(Unknown Source)
      at org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source)
      at com.sun.org.apache.xalan.internal.xsltc.trax.SAX2DOM.startElement(SAX2DOM.java:141)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandler.java:205)
      at com.sun.org.apache.xml.internal.serializer.ToSAXHandler.flushPending(ToSAXHandler.java:291)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startElement(ToXMLSAXHandler.java:646)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.startElement(ToXMLSAXHandler.java:508)
      at transform.template$dot$0()
      at transform.applyTemplates()
      at transform.transform()
      at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:594)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
      Does anyone know how can I do it?

      Thanks,
      Daniel