From: Dan O. <dan...@gm...> - 2005-07-12 00:00:19
|
I have encountered a similar issue using the latest stable version of exist 1.0b2 and the XMLdbGUI instructions at the bottom of this page: http://exist.sourceforge.net/deployment.html The namespace attribute is stripped out in the document created fromthe embedded mode. I used the following XML document: <?xml version=3D"1.0" encoding=3D"ISO-8859-1"?> <test:content xmlns:test=3D"http://somewhere.com/xmlns/someproduct/"> <test:contentdata>somedata</test:contentdata> </test:content> When I pull the document out of the DB in embedded mode, this is the XML that comes back: <?xml version=3D"1.0" encoding=3D"ISO-8859-1"?> <test:content> <test:contentdata>somedata</test:contentdata> </test:content> When I pull the document out of the DB in xmlrpc mode, this is the XML that comes back: <?xml version=3D"1.0" encoding=3D"ISO-8859-1"?> <test:content xmlns:test=3D"http://somewhere.com/xmlns/someproduct/"> <test:contentdata>somedata</test:contentdata> </test:content> Anyone have a fix for this? thanks! dan >"Gary Larsen" <gar...@en...> wrote in message news:E1D...@sc...... >I'm converting an application from Xindice to eXist and noticing differences in behavior with setContentAsDOM and >getContentAsDOM methods with documents using namespace prefixes. >=20 >When using the setContentAsDOM to load a document an exception occurs that seems to be a namespace issue: >=20 >java.lang.NullPointerException > at java.util.Hashtable.get(Hashtable.java:333) > at org.xml.sax.helpers.NamespaceSupport$Context.getURI(Namespa= ceSupport.java:576) > at org.xml.sax.helpers.NamespaceSupport.getURI(NamespaceSuppor= t.java:301) > at org.exist.util.serializer.DOMSerializer.startNode(DOMSerial= izer.java:140) > at org.exist.util.serializer.DOMSerializer.serialize(DOMSerial= izer.java:77) > at org.exist.xmldb.RemoteXMLResource.setContentAsDOM(RemoteXML= Resource.java:280) >=20 >I resolved this by using the setContent method as I had the XML string available. >=20 >=20 >The problem with getContentAsDOM only occurs when running in embedded mode. The unit tests using the XMLRPC >mode work without error. I'm extracting the DOM from the collection and then using XPathAPI to query the document: >=20 >javax.xml.transform.TransformerException: Prefix must resolve to a namespace: nv > at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:64= 9) > at org.apache.xpath.compiler.Lexer.mapNSTokens(Lexer.java:676) > at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:303) > at org.apache.xpath.compiler.Lexer.tokenize(Lexer.java:134) > at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.jav= a:155) > at org.apache.xpath.XPath.<init>(XPath.java:202) > at org.apache.xpath.XPathAPI.eval(XPathAPI.java:279) > at org.apache.xpath.XPathAPI.selectNodeIterator(XPathAPI.java:172) > at org.apache.xpath.XPathAPI.selectSingleNode(XPathAPI.java:133) >=20 >With logging I was able to determine that the xmlns attribute is not included in the document element when using the >getContentAsDOM method in embedded mode. (This works OK using xmlrpc) >=20 >I guessing a work around would be to use getContent and load the DOM myself, but that seems like unnecessary overhead. >=20 >Thanks for any assistance, >Gary >=20 > |