Hi all...
I have a problem with JAXB on some XML schema's that validate correctly in both XMLSpy and XSDValid. It seems to be a problem with imports, since rearranging them changes the error message.
I've tried to create a simle example that shows the error, containing two imported schema's and one that uses them.
Imported:
<?xml version="1.0"?>
<schema targetNamespace="Tester"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<simpleType name="NonEmptyString">
<restriction base="string">
<minLength value="1"/>
</restriction>
</simpleType>
</schema>
<?xml version="1.0"?>
<schema targetNamespace="Tester"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<simpleType name="PositiveNumber">
<restriction base="integer">
<minInclusive value="0"/>
</restriction>
</simpleType>
</schema>
... and the one that uses the above schemas:
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="Foo"
xmlns:test="Tester"
xmlns="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
<import namespace="Tester" schemaLocation="SimpleNumber.xsd"/>
<import namespace="Tester" schemaLocation="SimpleString.xsd"/>
<complexType name="StringNumber">
<annotation>
<documentation>Something containing a String and a Number.</documentation>
</annotation>
<sequence>
<element name="aString" type="test:NonEmptyString" minOccurs="0"/>
<element name="aNumber" type="test:PositiveNumber" minOccurs="0"/>
</sequence>
</complexType>
</schema>
It should be said that my experince with XML schemaes are somewhat limited, so be gentle ;-). But my own theory is that it only reads the first import (perhaps because they have the same namespace (???)), since the error changes from the line using NonEmptyString to PositiveNumber, when i rearrange the import statements.
The errormessage, when JAXB compiling the above (with Ant), is:
[xjc] Compiling file:/U:/Gas/vejman/SchemaTest.xsd
[xjc] [ERROR] src-resolve: Cannot resolve the name 'test:NonEmptyString' t
o a(n) type definition component.
[xjc] line 16 of SchemaTest.xsd
Thanx
/Dennis