Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1175

The Xerces implemented SchemaFactory is not used by default when using Xerces 2.8.0 with Java 5.0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Invalid
    • 2.8.0
    • None
    • None
    • Java 5.0
      Xerces 2.8.0
      Eclipse 3.2

    Description

      When version 2.8.0 of xercesImpl.jar is added to the Java 5.0 classpath the Xerces implementation of SchemaFactory is not used by default.

      The reason for this is that the content of the file META-INF/services/javax.xml.validation.SchemaFactory in xercesImpl.jar is

      org.apache.xerces.jaxp.validation.XMLSchemaFactory

      It should be

      http\://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory

      (note the escape character of the : after http) as Java 5.0 expects a SchemaFactory for each schema language in this case http\://www.w3.org/2001/XMLSchema

      When running the following with Java 5.0 and version 2.8.0 of xercesImpl.jar on the classpath

      import javax.xml.XMLConstants;
      ...

      SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
      System.out.println(factory.getClass().getName());

      the output is

      com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl

      Which is the Java 5.0 (Xerces 2.6.2 derivate) build-in SchemaFactory and not the Xerces 2.8.0 SchemaFactory.

      There are several workarrounds one is to run java with the option

      -Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory

      Others are to use $java.home/lib/jaxp.properties or set the system property using System.setProperty(...). See http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/validation/SchemaFactory.html#newInstance(java.lang.String) for a description of how the SchemaFactory implementation is found.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sgjesse Søren Gjesse
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: