users@jaxb.java.net

Re: Issues with Unmarshaller and setSchema for jaxb-2.1.9

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Fri, 10 Apr 2009 13:09:26 +0200

It's too difficult to guess from your narrative. Plz provide full .xsd and
.xml code, reduced to the essentials, showing the problem.
-W

On Fri, Apr 10, 2009 at 12:26 AM, John Sisson <john.sisson_at_miles33.com>wrote:

> 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 PMcom.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 PMcom.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 PMcom.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
>
>
>
>
>