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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

include schemas in JAXB beta

843834Nov 11 2002 — edited Nov 19 2002
Hi I am using <xsd:include> in my xsd file to refer to elements defined in another xsd.

When I compiled my xsd, xjc complains:
parsing a schema...
src-include.0: Failed to read included schema document 'COS.xsd'.
line 5 of Payment.xsd

src-resolve: Cannot resolve the name 'InstructionKeyInfo' to a(n) >elment declaration component.
line 29 of Payment.xsd

Failed to parse a schema.
Does JAXB 1.0 supports xsd:include?

Thanks!

Joe

My xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema version="$Id$" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" >

<xsd:include schemaLocation="COS.xsd"/>
<xsd:annotation>
<xsd:appinfo>
<jxb:globalBindings
fixedAttributeAsConstantProperty="true"
collectionType="java.util.Vector"
typesafeEnumBase="xsd:NCName"
choiceContentProperty="false"
typesafeEnumMemberName="generateError"
modelGroupAsClass="false"
enableFailFastCheck="false"
generateIsSetMethod="false"
underscoreBinding="asCharInWord">

</jxb:globalBindings>
<jxb:schemaBindings>
<jxb:package name="com.hsbc.gib.tools.cos.beans"/>
</jxb:schemaBindings>
</xsd:appinfo>
</xsd:annotation>

<xsd:element name="PaymentInstructionReq">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="InstructionKeyInfo" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>


</xsd:schema>

Comments

843834
It doesn't itself, but since you can feed jaxb a DOM document from any source, you can always use a processor that does support xinclude and feed the result to the unmarshaller. Try this:

(1) Get the XInclude Engine at http://xincluder.sourceforge.net/

(2) build the xinclude document with something like:


DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware( true );
factory.setCoalescing( true );
DocumentBuilder parser = factory.newDocumentBuilder();
InputSource input = new InputSource();
input.setByteStream( new FileInputStream( fname ) );
Document masterDoc = parser.parse( input );
Document doc = DOMXIncluder.merge( masterDoc, input.getSystemId() );

(3) then unmarshal the document with:

JAXBContext jc = JAXBContext.newInstance( "my.context" );
Unmarshaller u = jc.createUnmarshaller();
MyClass x = (MyClass) u.unmarshal( doc );

there's probably a faster Sax equivalent of this. Also works (better) with Castor.

hope this helps,

Graham
843834
Oops! sorry: looking at it again, I see I misread your question. I thought you meant using xinclude in a datafile (which I'd just worked out how to do) rather than in a schema (which I haven't worked out). Apologies.

Graham
843834
Yes. JAXB 1.0 supports included and imported schemas.
Can you please attach the COS.xsd too

Regards,
Bhakti Mehta
Sun Microsystems
1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 17 2002
Added on Nov 11 2002
3 comments
88 views