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

"Validation error: cvc-elt.1: Cannot find the declaration of element 'phonebook'." where Java 1.5.0 validator works.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 2.7.1
    • None
    • XML Schema API
    • None
    • OS X, Java 1.5.0

    Description

      I'm trying to make use of the newish javax.xml.validation APIs. I can get them to work with the Xerces built in to Java 1.5 but not with Xerces 2.7.1. I've got a project still on Java 1.4, so I need to get a non-bundled Xerces working.

      I'm testing with the sample code available from <http://www-128.ibm.com/developerworks/xml/library/x-jaxp/>

      [slamb@dhcp-105 /tmp]$ java -version
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-83)
      Java HotSpot(TM) Client VM (build 1.5.0_05-48, mixed mode, sharing)

      $ curl -O ftp://www6.software.ibm.com/software/developer/library/x-jaxp-all-about.zip
      $ unzip x-jaxp-all-about.zip
      $ javac TestDOMValidation.java

      Xerces 2.7.1's SchemaFactory implementation errors out:

      java \
      -classpath $HOME/.maven/repository/xerces/jars/xercesImpl-2.7.1.jar:. \
      -Djaxp.debug=true \
      -Djavax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema=org.apache.xerces.jaxp.validation.XMLSchemaFactory \
      TestDOMValidation simple.xml simple.xsd
      JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
      JAXP: found jar resource=META-INF/services/javax.xml.parsers.DocumentBuilderFactory using ClassLoader: sun.misc.Launcher$AppClassLoader@a9c85c
      JAXP: found in resource, value=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
      JAXP: created new instance of class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl using ClassLoader: sun.misc.Launcher$AppClassLoader@a9c85c
      JAXP: using thread context class loader (sun.misc.Launcher$AppClassLoader@a9c85c) for search
      JAXP: Looking up system property 'javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema'
      JAXP: The value is 'org.apache.xerces.jaxp.validation.XMLSchemaFactory'
      JAXP: instanciating org.apache.xerces.jaxp.validation.XMLSchemaFactory
      JAXP: loaded it from jar:file:/Users/slamb/.maven/repository/xerces/jars/xercesImpl-2.7.1.jar!/org/apache/xerces/jaxp/validation/XMLSchemaFactory.class
      JAXP: factory 'org.apache.xerces.jaxp.validation.XMLSchemaFactory' was found for http://www.w3.org/2001/XMLSchema
      Validation error: cvc-elt.1: Cannot find the declaration of element 'phonebook'.

      but the one built in to Java 1.5 works correctly:

      $ java -Djaxp.debug=true TestDOMValidation simple.xml simple.xsd
      JAXP: find factoryId =javax.xml.parsers.DocumentBuilderFactory
      JAXP: loaded from fallback value: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
      JAXP: created new instance of class com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl using ClassLoader: sun.misc.Launcher$AppClassLoader@a9c85c
      JAXP: using thread context class loader (sun.misc.Launcher$AppClassLoader@a9c85c) for search
      JAXP: Looking up system property 'javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema'
      JAXP: The property is undefined.
      JAXP: found null in $java.home/jaxp.properties
      JAXP: no META-INF/services/javax.xml.validation.SchemaFactory file was found
      JAXP: attempting to use the platform default XML Schema validator
      JAXP: instanciating com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl
      JAXP: loaded it from jar:file:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/classes.jar!/com/sun/org/apache/xerces/internal/jaxp/validation/xs/SchemaFactoryImpl.class
      JAXP: factory 'com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl' was found for http://www.w3.org/2001/XMLSchema
      JAXP: find factoryId =javax.xml.transform.TransformerFactory
      JAXP: loaded from fallback value: com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
      JAXP: created new instance of class com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl using ClassLoader: sun.misc.Launcher$AppClassLoader@a9c85c
      Document validates fine.

      xmllint also works fine with these files:

      $ xmllint --schema simple.xsd simple.xml
      [...]
      simple.xml validates

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              slamb@slamb.org Scott Lamb
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: