users@jaxb.java.net

Issues with Unmarshaller and setSchema for jaxb-2.1.9

From: John Sisson <john.sisson_at_miles33.com>
Date: Thu, 9 Apr 2009 15:26:59 -0700

Hello

I am working with jaxb-2.1.9

 

I have two schemas MyBase.xsd and MyExtended.xsd which extends MyBase
(by <import>) in the same namespace ("http://my.me.com/mystuff") and
these are packaged in the jar/working classpath of a reader application
which loads them both using the contextClassloader as InputStream[] and
creates a newSchema(Source[]) and assigns it to an Unmarshaller.

 

The implementation of Schema appears to be order sensitive; if Base
precedes Extended in Source[], I cannot unmarshal <ExtendedItem> from an
xml file as the unmarshaller claims there is no definition for it.

==

Apr 9, 2009 3:14:53 PM com.me.my.xml.toys.MyMarshallingBase reportError

SEVERE: XmlValidationEvent: Fatal: 'cvc-elt.1: Cannot find the
declaration of element 'MyExtendedItem'.' @ lin:2 col:50 off:-1
@NoObject

Apr 9, 2009 3:14:53 PM com.me.my.scd.test.TestScd main

SEVERE: Failed test

javax.xml.bind.UnmarshalException

 - with linked exception:

[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration
of element 'MyExtendedItem'.]

       at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException
(AbstractUnmarshallerImpl.java:315)

==

 

If I set the order {Extended, Base} and load a Schema, the unmarshalling
succeeds; however an ErrorHandler on the Schema notes the following as
it loads up (which does not happen for the order {Base,Extended}

==

Apr 9, 2009 3:18:46 PM
com.me.my.xml.toys.MySchemaHelper$MySchemaErrorHandler error

SEVERE: SchemaParserError: @26::46 id:null 'src-resolve: Cannot resolve
the name 'PersonGroup' to a(n) 'group' component.'

Apr 9, 2009 3:18:46 PM
com.me.my.xml.toys.MySchemaHelper$MySchemaErrorHandler error

SEVERE: SchemaParserError: @33::46 id:null 'src-resolve: Cannot resolve
the name 'PersonGroup' to a(n) 'group' component.'

Apr 9, 2009 3:18:46 PM
com.me.my.xml.toys.MySchemaHelper$MySchemaErrorHandler error

SEVERE: SchemaParserError: @45::40 id:null 'src-resolve: Cannot resolve
the name 'MyBaseItem' to a(n) 'element declaration' component.'

==

 

It seems as though the Schema does not handle the concept of <import>
correctly; at least there should be a note about order sensitivity; at
best a way to declare dependencies.

Thanx

John Sisson