Re: Convert XMLFragment to DOM node (solved)
The problem was, that I hadn't sent the startDocument and endDocument events. - Original Message - From: Christian Kurz To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Monday, October 21, 2002 12:09 AM Subject: Re: Convert XMLFragment to DOM node I am experiencing the same problem. Have you been able to solve this problem? Any hints? Thanks in advance, Christian
Re: Convert XMLFragment to DOM node
I am experiencing the same problem. Have you been able to solve this problem? Any hints? Thanks in advance, Christian
Re: Convert XMLFragment to DOM node
I'm not sure if anyone answered this... But a couple of things 1.) what's a XMLFragment - is this a cocoon class??? And what really is an XMLFragment, e.g. is it a org.w3c.dom.DocumentFragment. If so a DocumentFragment is already a node so no need for a conversion. DocumentFragments are used throughout the authentication and session pieces of code... 2.) As to the NULL pointer another clue maybe the following. If a XMLFragment is really derived from a w3c.dom node... and you've created a document, and then a node (dummy). Basically these two set's of nodes (dummy vs the XMLFragment) are from different documents and to get one into the other you need to import it otherwise you get null pointer exceptions. Your appending in a fragment from another document and that typically doesn't work until you import the fragment in. Look at either the Document or the node class for an import method. Not sure if that helps, md - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faq/index.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Convert XMLFragment to DOM node
I'm using jre 1.4.1. I have an xsp which captures a fragment of xml, and passes it to a class: capture:fragment-variable name=frag foobar//foo /capture:fragment-variable xsp:logic MyClass.doSomething(frag); /xsp:logic This passes an XMLFragment which I convert to a node: public class MyClass { public static void doSomething(XMLFragment frag){ Node node = frag2Node(frag); ... } public Node frag2Node(XMLFragment frag){ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDo cument(); Node dummy = doc.createElement(dummy); doc.appendChild(dummy); frag.toDOM(dummy); return dummy.getFirstChild(); } When Cocoon runs, I get an exception in the call to frag.toDOM(dummy) It is a null pointer exception java.lang.NullPointerException at org.apache.xalan.transformer.TransformerIdentityImpl.flushStartDoc(T ransformerIdentityImpl.java:885) at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(Tr ansformerIdentityImpl.java:1016) at org.apache.cocoon.xml.AbstractXMLPipe.startElement(AbstractXMLPipe.j ava:130) at org.apache.cocoon.xml.AbstractXMLPipe.startElement(AbstractXMLPipe.j ava:130) at org.apache.cocoon.components.sax.XMLByteStreamInterpreter.parse(XMLB yteStreamInterpreter.java:126) at org.apache.cocoon.components.sax.XMLByteStreamInterpreter.deserializ e(XMLByteStreamInterpreter.java:102) at org.apache.cocoon.components.sax.XMLByteStreamFragment.toSAX(XMLByte StreamFragment.java:100) at org.apache.cocoon.xml.AbstractSAXFragment.toDOM(AbstractSAXFragment. java:76) Can anyone see what the problem is - I've searched in vain! Alternatively, is there a more elegant way of converting the XMLFragment passed by Cocoon as a parameter into a DOM node?! Robert Onslow ** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com ** - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faq/index.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]