Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-3050

Reading indented XML using SAAJ (which uses AXIOM) treats line breaks and spaces as text nodes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.3
    • None
    • om
    • None
    • All

    Description

      I am trying to read this XML snippet:

      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
      <soapenv:Body>
      <get_registryInfo generic="1.0" xmlns="urn:juddi-org:api_v2"/>
      </soapenv:Body>
      </soapenv:Envelope>

      Using this code to read in and process:

      String s = <the xml snippet>
      MessageFactory msgFactory = MessageFactory.newInstance();
      SOAPMessage soapReq = msgFactory.createMessage(null,new ByteArrayInputStream(s.getBytes()));
      SOAPBody soapReqBody = soapReq.getSOAPBody();

      Then, on this line:

      Node n = soapReqBody.getFirstChild();

      The node returned on this call is a Text node with a value of "\n " (line break with spaces). In other words, the code handles the indenting up until the SOAPBody element is isolated. Then calling the getFirstChild() method returns the indenting as a Text node. Stepping into the code reveals that the getFirstChild() method comes from SAAJ's SOAPElementImpl. This in turn calls getFirstChild() from it's element member variable which is of type SOAP11BodyImpl from AXIOM. It is this call that is returning the indentation.

      Not sure if this is a bug or if AXIOM doesn't allow indented XML.

      Attachments

        Activity

          People

            sumedha Sumedha Rubasinghe
            footh Jeff Faath
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: