Hello,
On 24 August 2010 15:33, Young Matthew (4004) <
matthew.young_at_forsakringskassan.se> wrote:
> Using latest JAXB (Suns)....
>
> Built up a hierarchy of schemas which rely heavy on extensions. So right
> now I have a lot of schemas that import each other (see below).
>
Hopefully not really "each other" :-)
> When creating a SchemaFactory the inputed sources have to be in the
> correct order (ie. commons.xsd before pojo.xsd because pojo.xsd imports
> commons.xsd). Otherwise type information isn't found. This is problem if I
> don't want to know the dependency (import) order prior to creating a Schema
> instance. Anyway to get around this? Using the import directives since
> constructing Java pojos from the schemas.
>
If @schemaLocation contains the correct URL, using schemaFactory.newSchema(
URL_of_pojo_xsd ) should be sufficient.
-W
>
>
> *commons.xsd*
> <xs:schema xmlns="http://www.klistret.com/cmdb/ci/commons"
> targetNamespace="http://www.klistret.com/cmdb/ci/commons"
> xmlns:xs=http://www.w3.org/2001/XMLSchema
> elementFormDefault="qualified">
> .....
> <xs:complexType name="Element" abstract="true">
> <xs:complexContent>
> <xs:extension base="Base">
> <xs:sequence>
> <xs:element name="Ownership" type="Ownership"
> maxOccurs="1" />
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
> ....
> </xs:schema>
>
> *pojo.xsd*
> <xs:schema xmlns="http://www.klistret.com/cmdb/ci/pojo"
> targetNamespace="http://www.klistret.com/cmdb/ci/pojo"
> xmlns:commons="http://www.klistret.com/cmdb/ci/commons"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <xs:import namespace=http://www.klistret.com/cmdb/ci/commons schemaLocation="commons.xsd"
> />
> .....
>
> <xs:complexType name="Element">
> .....
> <xs:element name="configuration" type="commons:Element"
> maxOccurs="1" minOccurs="1" />
> ....
>
> </xs:complexType>
>
> </xs:schema>
>
>