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

InternalError while importing a Notation node with Document.importNode()

    XMLWordPrintable

Details

    • 1.1fcs
    • sparc
    • solaris_7

    Description



      Name: inR10064 Date: 12/08/2000



        JAXP 1.1 method org.w3c.dom.Document.importNode(Node importedNode, boolean deep)
      throws an java.lang.InternalError while importing a Notation node from another
      document into current document (See test.java below).

        Definition of the method in p. 1.2 "Fundamental Interfaces" of DOM Level 2 Core
      (http://www.w3.org/TR/2000/PR-DOM-Level-2-Core-20000927/core.html#ID-1780488922)
      says:

      " importNode introduced in DOM Level 2
              Imports a node from another document to this document.
              .....
              NOTATION_NODE
                 Notation nodes can be imported, however in the current release of the DOM
                 the DocumentType is readonly. Ability to add these imported nodes to a
                 DocumentType will be considered for addition to a future release of the
                 DOM.
                 On import, the publicId and systemId attributes are copied.
                 Note that the deep parameter has no effect on Notation nodes since they
                 never have any children. "
                 
      This bug appears in builds jaxp-1.1ea-b09, jaxp-1.1ea2-b10, jaxp-1.1ea2-b11,
      jaxp-1.1ea2-b12, jaxp-1.1ea2-b13, jaxp-1.1ea2-b14 and affects the new test in TCK
      JAXP 1.1

      api/org_w3c_dom/Document/ImportNodeTests.html#importNodeTest015
           
      ------------------------------------test.java-----------------------------
      import org.w3c.dom.Document;
      import org.w3c.dom.Notation;
      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.parsers.DocumentBuilder;
      import java.io.ByteArrayInputStream;

      public class test {
          
          public static void main(String argv[]) {
              
              try {
                  DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance()
                                                    .newDocumentBuilder();

                  Document firstDoc = documentBuilder.newDocument();

                  String data =
                  "<?xml version=\"1.0\" ?>" +
                  "<!DOCTYPE root [" +
                  "<!ELEMENT root ANY>" +
                  "<!NOTATION e PUBLIC \"http://xxx.xxx.xxx/\">" +
                  "]>" +
                  "<root/>";
              
                  ByteArrayInputStream in = new ByteArrayInputStream(data.getBytes());

                  Document secondDoc = documentBuilder.parse(in);
              
                  Notation importedNotation = (Notation)secondDoc.getDoctype()
                                              .getNotations().item(0);
              
                  Notation notation = (Notation)firstDoc.importNode(importedNotation,
                                                                    false);
                  
                  System.out.println("The notation node was imported.");
              } catch (Exception e) {
                  System.out.println("Unexpected exception: " + e);
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -showversion -cp .:jaxp1.1ea-b08/jaxp.jar:jaxp1.1/crimson.jar test
      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, interpreted mode)

      The notation node was imported.

      % java -showversion -cp .:jaxp1.1ea-b09/jaxp.jar:jaxp1.1ea-b09/jaxp.jar test
      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, interpreted mode)

      Exception in thread "main" java.lang.InternalError: org.apache.crimson.tree/TW-000
      12
              at org.apache.crimson.tree.TreeWalker.getNext(TreeWalker.java:185)
              at org.apache.crimson.tree.XmlDocument.importNode(XmlDocument.java:1299)
              at test.main(test.java:31)
      ---------------------------------------------------------------------------

      ======================================================================

      Attachments

        Activity

          People

            egoei Edwin Goei (Inactive)
            inevsunw Inev Inev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: