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

SAXParserFactory.getFeature() always throws an exception

XMLWordPrintable

    • 1.1fcs
    • generic
    • generic
    • Verified



      Name: inR10064 Date: 10/17/2000



       JAXP 1.1 method javax.xml.parsers.SAXParserFactory.getFeature(String name)
      throws an SAXNotRecognizedException when invoked with argument
      "http://xml.org/sax/features/namespaces" (See test1.java below).
      But this feature should be recognized by the method.

      p. 4.1.9 "public abstract boolean getFeature(String name)" of JAXP 1.1 spec
      (jaxp-pd1.pdf) reads :

      " Throws a SAXNotSupportedException if the underlying parser
        recognizes but doesn't support the option. "

      SAX 2.0 specification (http://www.megginson.com/SAX/Java/features.html) requires
      that all org.xml.sax.XMLReader implementations should recognize and support the
      "http://xml.org/sax/features/namespaces" and the
      "http://xml.org/sax/features/namespace-prefixes" features.
       
      Note that the method org.xml.sax.XMLReader.getFeature() works correctly with
      same parameter (See test2.java below).

      This bug present in builds jaxp-1.1ea-b8 and jaxp-1.1fcs-b9 and affects
      new tests in TCK JAXP 1.1

      api/javax_xml_parsers/SAXParserFactory/GetFeatureTests.html
      api/javax_xml_parsers/SAXParserFactory/SetFeatureTests.html


      ------------------------------------test1.java-----------------------------
      import javax.xml.parsers.SAXParserFactory;
      import org.xml.sax.SAXNotRecognizedException;
       
      public class test1 {
           
          public static void main(String argv[]) {
                       
              try {
                  SAXParserFactory factory = SAXParserFactory.newInstance();
                   
                  factory.getFeature("http://xml.org/sax/features/namespaces");
                   
                  System.out.println("OKEY");
              } catch (SAXNotRecognizedException e) {
                  System.out.println("The feature 'http://xml.org/sax/features/namespaces' wasn't recognized.");
              } catch (Throwable e) {
                  System.out.println("Unexpected exception: " + e);
              }
          }
      }
      ---------------------------------------------------------------------------

      ------------------------------------test2.java-----------------------------
      import javax.xml.parsers.SAXParserFactory;
      import org.xml.sax.SAXNotRecognizedException;
      import org.xml.sax.XMLReader;
       
      public class test2 {
           
          public static void main(String argv[]) {
                       
              try {
                  XMLReader parser = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
                   
                  parser.getFeature("http://xml.org/sax/features/namespaces");
                   
                  System.out.println("OKEY");
              } catch (SAXNotRecognizedException e) {
                  System.out.println("The feature 'http://xml.org/sax/features/namespaces' wasn't recognized.");
              } catch (Throwable e) {
                  System.out.println("Unexpected exception: " + e);
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -version
      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)
       
      % java test1
      The feature 'http://xml.org/sax/features/namespaces' wasn't recognized.
       
      % java test2
      OKEY
      ---------------------------------------------------------------------------
       
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: