Uploaded image for project: 'Axiom'
  1. Axiom
  2. AXIOM-259

AXIOM DOM based org.w3c.dom.Element.getElementsByTagName and getElementsByTagNameNS do not funcion according to spec

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.2.8
    • None
    • None

    Description

      The w3c spec states:
      getElementsByTagName
      Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree.

      It looks that current implementation of org.apache.axiom.om.impl.dom.ElementImpl looks only at the 1st level of children and not through the tree.

      Here is the code snippet

      //Instantiate and parse soap message with AXIOM DOM
      DocumentBuilderFactoryImpl.setDOOMRequired(true);
      Document doc =DocumentBuilderFactoryImpl.newInstance().newDocumentBuilder().parse(new FileInputStream(SOAP_EXAMPLE_XML));
      nl = doc.getDocumentElement().getElementsByTagName("return");
      System.out.println("AXIOM DOM XML Parser found " + nl.getLength() + " element(s)"); //AXIOM DOM XML Parser found 0 element(s)

      // Instantiate and parse document with xerces
      System.getProperties().setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setNamespaceAware(true);
      doc = dbf.newDocumentBuilder().parse(new FileInputStream(SOAP_EXAMPLE_XML));
      nl = doc.getDocumentElement().getElementsByTagName("return");
      System.out.println("XERCES XML Parser found " + nl.getLength() + " element(s)"); // XERCES XML Parser found found 1 element(s)

      SOAP_EXAMPLE_XML.file:
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <xsd:startSessionResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <return xsi:type="xsd:string">sessionID</return>
      </xsd:startSessionResponse>
      </soapenv:Body>
      </soapenv:Envelope>

      Attachments

        Activity

          People

            veithen Andreas Veithen
            gshumakher Gennady Shumakher
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: