Xerces and Saxon incompatible wrt namespaces

  • sid

    sid - 2004-12-06


    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.


    Test Case

    public static void testSoap(){
    System.setProperty( "javax.xml.parsers.DocumentBuilderFactory","net.sf.saxon.om.DocumentBuilderFactoryImpl");
    // set Saxon Doc
    DocumentBuilderFactory dbFactory= DocumentBuilderFactory.newInstance();
    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();
        builder = dbFactory.newDocumentBuilder();
        Document document2 = builder.newDocument();
        System.out.println("Saxon Doc : ");
        System.out.println("\nXerces Doc : ");
        }catch(Exception ex){

    <m:GetLastTradePrice xmlns:m="http://wombat.ztrade.com">
    <n:symbol xmlns:n="http://wombat.ztrade.com">SUNW</n:symbol>

    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">SUNW</n:symbol>

    Xerces Doc :
    <?xml version="1.0" encoding="UTF-8"?>

    • Michael Kay

      Michael Kay - 2004-12-06

      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

    • sid

      sid - 2004-12-06

      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

      -thanks for ur help


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks