Java Mailing List Archive

http://www.junlu.com/

Home » user.castor »

[castor-user] xsi:type and hierarchy definition

drowelbuod

2012-05-29

Replies: Find Java Web Hosting

Author LoginPost Reply

Hello.

I want to marshal an object to an XML with Castor.

To do so, I used the castor XML conversor to generate the Java classes from
the XSD files.

When I marshal an object using the generated classes I get an XML.
But there is problem in the XML generated when the xsi:type is required to
reference a subclass, because I don't get the reference to the namespace
defined in the XSD of the subclass.

So I get:
...
<bodyContent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="getUser">
...

But I would like to obtain something like:
...
<bodyContent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="bn:getUser">
...

Or something like:
...
<bodyContent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="B:getUser">
...


With this definition of XSD files used:
File A.xsd
...
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:an="http://www.mydefinition.com/A"
targetNamespace="http://www.mydefinition.com/A"
elementFormDefault="qualified">
...
<xsd:complexType name="bodyContentType"/>
...


File B.xsd
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:an="http://www.mydefinition.com/A"
xmlns:bn="http://www.mydefinition.com/B"
targetNamespace="http://www.mydefinition.com/B"
elementFormDefault="qualified">
<xsd:import namespace="http://www.mydefinition.com/A"
schemaLocation="./A.xsd"/>
...
<xsd:complexType name="getUser" >
 <xsd:complexContent>
   <xsd:extension base="an:bodyContentType">
     <xsd:sequence>
       <xsd:element name="webExId" type="xsd:string"/>
     </xsd:sequence>
   </xsd:extension>
 </xsd:complexContent>
</xsd:complexType>
...


The XML conversor of Castor doesn't add the namespace information to
generate it.

How can force to add this information in the generation?
May be I need change something in the XSD files?

Thanks in advance.

--
Sent from the Castor - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 junlu.com - Jax Systems, LLC, U.S.A.