Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JAXB compilation error (schema)

843834Aug 1 2003 — edited Aug 20 2003
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 17 2003
Added on Aug 1 2003
2 comments
264 views