Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4391317

com.sun.xml.tree.TreeWalker skips children of entity reference nodes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.3.0
    • Fix Version/s: 1.1
    • Component/s: xml
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.1fcs
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: krC82822 Date: 11/21/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      This is jaxp 1.0.1

      With documents that contain external entity reference nodes, the method
      getElementsByTagName(String) does not return any matching elements within
      the actual entity.

      In the tr2 version of the parser, any matching elements within the external
      entity were returned.

      This was tracked down to the following

      1) The tr2 parser seems to leave only com.sun.xml.tree.ElementNode objects
      in the DOM tree
      2) jaxp 1.0.1 changed this, creating com.sun.xml.tree.XmlDocument$EntityRefNode
      for entity reference nodes, and placing them in the DOM tree
      3) TreeWalker skips children of entity reference nodes, but that
      did not matter for the tr2 parser.

      ==== begin Test.java ====
      import org.w3c.dom.*;
      import com.sun.xml.tree.XmlDocument;
      import com.sun.xml.tree.XmlDocumentBuilder;
      import com.sun.xml.parser.ValidatingParser;

      public class Test {

          public static void main(String[] args) {

              try {
                  Document doc = null;
                  ValidatingParser parser = new ValidatingParser();
                  XmlDocumentBuilder builder = new XmlDocumentBuilder();
                  builder.setParser(parser);
                  parser.parse("file:///C:/temp/main.xml");
                  doc = builder.getDocument();
                  Element root = doc.getDocumentElement();
                  NodeList n = root.getElementsByTagName("table");
                  System.out.println("Elements Matching = " + n.getLength());
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      ==== end Test.java ====

      ==== begin main.xml ====
      <?xml version="1.0" standalone="no"?>
      <!DOCTYPE main [
      <!ELEMENT main (table)*>
      <!ELEMENT table (column)*>
      <!ATTLIST table name NMTOKEN #REQUIRED>
      <!ELEMENT column EMPTY>
      <!ATTLIST column name NMTOKEN #REQUIRED>
      <!ATTLIST column expr CDATA #REQUIRED>
      <!ENTITY ee SYSTEM "ee.xml">
      ]>

      <main>
      &ee;
      </main>
      ==== end main.xml ====

      ==== begin ee.xml ====
      <?xml version="1.0" encoding="UTF-8"?>
      <table name="table">

      <column
      name="Column"
      expr="col"
      />

      </table>
      ==== end ee.xml ====

      Running the test class using tr1 finds 1 matching element, using
      jaxp 1.0.1 finds 0.
      (Review ID: 105243)
      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              egoei Edwin Goei (Inactive)
              Reporter:
              kryansunw Kevin Ryan (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: