|
Replies:
2
-
Last Post:
Aug 10, 2006 5:05 AM
by: neodante
|
|
|
|
|
|
|
XML Schema parsing failure
Posted:
Aug 9, 2006 1:36 AM
|
|
|
Hi, When I launch the compiler xjc to generate Java classes from a XML Schema dc.xsd :
C:\MyDir>xjc schemas/dc.xsd -p jaxbgen.dc -d gen parsing a schema... [ERROR] src-resolve: Cannot resolve the name 'xml:lang' to a(n) 'attribute decla ration' component. line 10 of file:/C:/Documents%20and%20Settings/JCHA/workspace/OpenXML4J/schema s/dc.xsd
[ERROR] s4s-elt-invalid-content.1: The content of 'SimpleLiteral' is invalid. E lement 'attribute' is invalid, misplaced, or occurs too often. line 10 of file:/C:/Documents%20and%20Settings/JCHA/workspace/OpenXML4J/schema s/dc.xsd
Failed to parse a schema.
So to discover the real problem, I decided to build a little app to validate my XSD and ... damn, xerces don't valid the dc.xsd schema :
Exception in thread "main" org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'xml:lang' to a(n) 'attribute declaration' component. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source) ...
This is exactly the same error message I have with xjc !
Here is the top lines of the dc.xsd :
<?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://purl.org/dc/elements/1.1/" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://purl.org/dc/elements/1.1/" > <xs:import namespace="http://www.w3.org/XML/1998/namespace" /> <xs:complexType name="SimpleLiteral"> <xs:complexContent mixed="true"> <xs:restriction base="xs:anyType"> <xs:sequence> <xs:any processContents="lax" minOccurs="0" maxOccurs="0" /> </xs:sequence> <xs:attribute ref="xml:lang" use="optional" /> </xs:restriction> </xs:complexContent> </xs:complexType> ...
Is something wrong in this schema (from the ECMA standards organization) or xerces bug or non implemented feature ???
Thanks in advance for your answers !
|
|
|
|
|
|
|
Re: XML Schema parsing failure
Posted:
Aug 9, 2006 5:26 PM
in response to: neodante
|
|
|
This is a very famous "feature" in the JAXP RI (or Xerces.) If your schema contains <xs:import> or <xs:include>, and if it fails to resolve --- whether because of network issue, proxy not set up, or some typo in the referenced document --- it simply ignores that error, without telling you anything!
But since the declarations that are supposed to be in those files are not defined, you'll end up getting errors like "can't find xml:lang".
A bug has been filed against the JAXP RI, so I hope we'll be able to fix it soon. I filed a similar bug against Xerces, but they refused to fix the bug, AFAIK.
In the mean time, the workaround is to use the "-nv" option in XJC, which bypasses the JAXP RI completely. JAXB will then use XSOM to parse the schemas, which will report errors on failed <xs:import>, and that error message should indicate what's wrong with your network set up.
(Most likely you are behind the firewall or something)
Ah, oh wait, well, in your case, your import statement to the schema doesn't have the schemaLocation attribute. So the JAXP RI, Xerces, and XSOM will simply ignore that.
You have to download the schema for "http://www.w3.org/XML/1998/namespace" and submit them to XJC alongside your schema.
|
|
|
|
|
|
|
|
Re: XML Schema parsing failure
Posted:
Aug 10, 2006 5:05 AM
in response to: kohsuke
|
|
|
A great thanks for yor help : it works !
Like you suggest, I download the XML schema and add a schemaLocation to the XSD with a -nv option in XJC
Thanks a lot !
|
|
|
|
|