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

ValidationHandler.getFeature() throws XMLConfigurationException

XMLWordPrintable

    • b36
    • generic
    • generic
    • Verified

        Name: eaR10174 Date: 12/18/2003


        The method

             javax.xml.validation.ValidationHandler.getFeature(String name)

        throws XMLConfigurationException in cases when the feature names are "unknown123" and
        "http://xml.org/sax/features/namespace-prefixes". According to the javadoc the method should
        throw SAXNotRecognizedException in case of first name and should not throw any exception in
        case of second name.

        The bug affects new JCK1.5 tests (not integrated yet):

          api/javax_xml/validation/ValidatorHandler/index.html#GetSetFeature[GetSetFeature002]
          api/javax_xml/validation/ValidatorHandler/index.html#GetSetFeature[GetSetFeature007]

        The following test fails running on JDK 1.5.0-beta-b31.
        See below the test source and the execution log:
        ------------------------------------test.java-----------------------------
        import javax.xml.validation.SchemaFactory;
        import javax.xml.validation.ValidatorHandler;
        import org.xml.sax.SAXException;
        import org.xml.sax.SAXNotRecognizedException;

        public class test {

             public static void main(String argv[]) {
                 new test().run();
             }

             public void run() {
                 SchemaFactory schemaFactory =
                     SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
                 ValidatorHandler validatorHandler = null;
                 try {
                     validatorHandler = schemaFactory.newSchema().newValidatorHandler();
                 } catch (SAXException e) {
                     e.printStackTrace();
                     return;
                 }

                 try {
                     validatorHandler.getFeature("unknown1234");
                     System.out.println("SAXNotRecognizedException was not thrown.");
                 } catch (SAXNotRecognizedException e) {
                     System.out.println("getFeature(unknown1234): OK");
                 } catch (Exception e) {
                     System.out.println(e.toString());
                 }

                 try {
                     if (!validatorHandler.getFeature("http://xml.org/sax/features/namespace-prefixes"))
                     {
                         System.out.println("getFeature(namespace-prefixes): OK");
                     } else {
                         System.out.println("Expected false, returned true.");
                     }
                 } catch (Exception e) {
                     System.out.println(e.toString());
                 }
             }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b31)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b31, mixed mode)

        com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException: unknown1234
        com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException:
        http://xml.org/sax/features/namespace-prefixes
        --------------------------------------------------------------------------

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

              kkawagucsunw Kohsuke Kawaguchi (Inactive)
              evgsunw Evg Evg (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: