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

Node.setPrefix() doesn't throw an exception on bad argument

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1fcs
    • CPU:
      sparc
    • OS:
      solaris_7
    • Verification:
      Verified

      Description



      Name: inR10064 Date: 12/18/2000


        
          The implementation of the method org.w3c.dom.Node.setPrefix(String prefix) doesn't throw DOMException
      when the parameter 'prefix' is invalid (See test.java below).
          Definition of the attribute prefix in p. 1.2 "Fundamental Interfaces" of DOM Level 2 Core
      (http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247) reads:
          
          " prefix of type DOMString, introduced in DOM Level 2
              ...
              Exceptions on setting
                DOMException INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal
                               character.

                               NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

                               NAMESPACE_ERR: Raised if the specified prefix is malformed, if the namespaceURI of
                               this node is null, if the specified prefix is "xml" and the namespaceURI of this
                               node is different from "http://www.w3.org/XML/1998/namespace", if this node is an
                               attribute and the specified prefix is "xmlns" and the namespaceURI of this node is
                               different from "http://www.w3.org/2000/xmlns/", or if this node is an attribute
                               and the qualifiedName of this node is "xmlns". "

        This bug is found in builds jaxp-1.1ea-b07, jaxp-1.1ea-b08, jaxp-1.1ea-b09,
      jaxp-1.1ea2-b10, jaxp-1.1ea2-b11, jaxp-1.1ea2-b12, jaxp-1.1ea2-b13, jaxp-1.1ea2-b14,
      jaxp-1.1ea2-b15 and affects the new tests in TCK JAXP 1.1:

      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest02
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest03
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest04
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest05
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest08
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest09
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest10
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest11
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest12
      api/org_w3c_dom/Node/SetPrefixTests.html#setPrefixTest13

      ------------------------------------test.java-----------------------------
      import org.w3c.dom.Document;
      import org.w3c.dom.Node;
      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.parsers.DocumentBuilder;

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

                  Document document = documentBuilder.newDocument();

                  Node element = null;
                  
                  element = document.createElementNS("http://xx.xx", "test:element");
                  element.setPrefix("!");
                  System.out.println("Set an invalid prefix \"!\"");

                  element = document.createElementNS("http://xx.xx", "test:element");
                  element.setPrefix("test::");
                  System.out.println("Set a malformed prefix \"test::\".");
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -showversion -cp .:jaxp1.1ea/jaxp.jar:jaxp1.1ea/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)

      Set an invalid prefix "!"
      Set a malformed prefix "test::".
      ---------------------------------------------------------------------------

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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: