Project

Profile

Help

Xerces and Saxon incompatible wrt namespaces

Added by Anonymous over 19 years ago

Legacy ID: #2883134 Legacy Poster: sid (siddharth_c)

hi When I build a saxon document and import the documentElement in a xerces Document I lose all the namespace declarations. Is this a known issue or a known bug or am i doing something wrong(which i think is the most likely option)? Unfortuantely due to xalans lack of proper support for xpath extension functions I have to mix Saxon and Xerces in my current SOAP project. I am posting my test case for your analysis Any light you can shed on this issue or point me to a possible workaround for this would be greatly appreciated. -thanks Siddharth Test Case public static void testSoap(){ try{ System.setProperty( "javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon.om.DocumentBuilderFactoryImpl"); // set Saxon Doc DocumentBuilderFactory dbFactory= DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); DocumentBuilder builder = dbFactory.newDocumentBuilder(); Document document = builder.parse("file:///c:\temp\test.xml"); System.setProperty( "javax.xml.parsers.DocumentBuilderFactory","org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); dbFactory= DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); builder = dbFactory.newDocumentBuilder(); Document document2 = builder.newDocument(); document2.appendChild(document2.importNode(document.getDocumentElement(),true)); System.out.println("Saxon Doc : "); printDocument(document,System.out,true); System.out.println("\nXerces Doc : "); printDocument(document2,System.out,true); }catch(Exception ex){ ex.printStackTrace(); } } Test.xml <m:GetLastTradePrice xmlns:m="http://wombat.ztrade.com"> <n:symbol xmlns:n="http://wombat.ztrade.com&quot;&gt;SUNW&lt;/n:symbol> </m:GetLastTradePrice> Output from the program : <?xml version="1.0" encoding="UTF-8"?> <m:GetLastTradePrice xmlns:m="http://wombat.ztrade.com"> <n:symbol xmlns:n="http://wombat.ztrade.com&quot;&gt;SUNW&lt;/n:symbol> </m:GetLastTradePrice> Xerces Doc : <?xml version="1.0" encoding="UTF-8"?> <m:GetLastTradePrice> <n:symbol>SUNW</n:symbol> </m:GetLastTradePrice>


Replies (2)

RE: Xerces and Saxon incompatible wrt namespa - Added by Anonymous over 19 years ago

Legacy ID: #2883198 Legacy Poster: Michael Kay (mhkay)

It looks as if Xerces is calling the DOM interfaces supplied by Saxon in some way that Saxon doesn't expect. This isn't greatly surprising because the way DOM handles namespaces is pretty bizarre, there are so many permutations possible, and it's always quite difficult to get the same result out of two different DOM implementations. I'll try to get a trace on what interfaces Xerces is calling to see if the situation can be fixed. Michael Kay

RE: Xerces and Saxon incompatible wrt namespa - Added by Anonymous over 19 years ago

Legacy ID: #2884324 Legacy Poster: sid (siddharth_c)

I found a thread on the xerces-j-user mailing list which was reporting a similar problem. That does not talk about saxon though. But the essence of the problem is the same. Unfortuantely the post went unanswered. FYI....and to help you debug http://marc.theaimsgroup.com/?l=xerces-j-user&amp;m=106730648807514&amp;w=4 -thanks for ur help Siddharth

    (1-2/2)

    Please register to reply