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

set LSResourceResolver doesn't work on SchemaFactory and Validator

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • 5.0
    • xml
    • x86
    • windows_2000

      FULL PRODUCT VERSION :
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Ver 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      set a LSResourceResolver to the SchemaFactory and Validator won't work.

                  SchemaFactory fact = ...
                  fact.setResourceResolver(new LSResourceResolver() {
                              public LSInput resolveResource(String type,
                                                             String namespaceURI,
                                                             String publicId,
                                                             String systemId,
                                                             String baseURI) {
                                  System.out.println("---- ---- FACTORY ---- ----");
                                  System.out.println("type = " + type);
                                  System.out.println("namespaceURI = " +
                                                     namespaceURI);
                                  System.out.println("publicId = " + publicId);
                                  System.out.println("systemId = " + systemId);
                                  System.out.println("baseURI = " + baseURI);
                                  System.out.println("---- ---- ---- ----");
                                  return null;
                              }
                          });
                  Validator val = JaxpValidatorDelegator.newValidator();
                  val.setResourceResolver(new LSResourceResolver() {
                              public LSInput resolveResource(String type,
                                                             String namespaceURI,
                                                             String publicId,
                                                             String systemId,
                                                             String baseURI) {
                                  System.out.println("---- ---- VALIDATOR ---- ----");
                                  System.out.println("type = " + type);
                                  System.out.println("namespaceURI = " +
                                                     namespaceURI);
                                  System.out.println("publicId = " + publicId);
                                  System.out.println("systemId = " + systemId);
                                  System.out.println("baseURI = " + baseURI);
                                  System.out.println("---- ---- ---- ----");
                                  return null;
                              }
                          });
                  val.validate(new StreamSource(file));

      the result doesn't contain any message. but if I use Xerces 2.9.1(org.apache.xerces.jaxp.validation.XMLSchemaFactory)
       I got the message like:

      ---- ---- VALIDATOR ---- ----
      type = http://www.w3.org/2001/XMLSchema
      namespaceURI = http://www.example.com/IPO/address
      publicId = null
      systemId = addressv2.xsd
      baseURI = file:///D:/Workspace/Zone/JAXP_Validation/commons_jaxp_validation/po/ipov2.xsd
      ---- ---- ---- ----

      It seems that the default one in JDK5(com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl) do not support setResourceResolver(LSResourceResolver resourceResolver).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should print out the message like:
      ---- ---- VALIDATOR ---- ----
      type = http://www.w3.org/2001/XMLSchema
      namespaceURI = http://www.example.com/IPO/address
      publicId = null
      systemId = addressv2.xsd
      baseURI = file:///D:/Workspace/Zone/JAXP_Validation/commons_jaxp_validation/po/ipov2.xsd
      ---- ---- ---- ----

      ACTUAL -
      Nothing printed out.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Using Xerces 2.9.1.

            joehw Joe Wang
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: