Hi all,
I am trying to use Castor 1.0M4 as my binding framework inside of XFire 1.2.6
but I am running into a namespace problem. I can reproduce the problem using
Castor 1.1 which is what I will describe now. I have a Castor mapping file
that defines the mapping for a class "order.Order" in the "http://order"
namespace. This order has an orderNumber and 2 names. The names are of type
"common.Name" which is in the "http://common" namespace. The mapping file
looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<mapping>
<class name="order.Order">
<map-to xml="order" ns-uri="http://order" ns-prefix="order"/>
<field name="orderNumber" type="integer">
<bind-xml name="order-number" node="element"/>
</field>
<field name="sellerName" type="common.Name">
<bind-xml name="seller-name" node="element"/>
</field>
<field name="buyerName" type="common.Name">
<bind-xml name="buyer-name" node="element"/>
</field>
</class>
<class name="common.Name">
<map-to xml="name" ns-uri="http://common" ns-prefix="common"/>
<field name="firstName" type="java.lang.String">
<bind-xml name="first-name" node="element"/>
</field>
<field name="lastName" type="java.lang.String">
<bind-xml name="last-name" node="element"/>
</field>
</class>
</mapping>
When I create an instance of Order and pass in an orderNumber and 2 names,
Castor generates the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<order:order xmlns:order="http://order">
<order:order-number>1234</order:order-number>
<common:seller-name xmlns:common="http://common">
<common:first-name>Bob</common:first-name>
<common:last-name>Smith</common:last-name>
</common:seller-name>
<common:buyer-name xmlns:common="http://common">
<common:first-name>Fred</common:first-name>
<common:last-name>Peterson</common:last-name>
</common:buyer-name>
</order:order>
The problem is that I cannot generate an XML schema for this (I want a schema
for my common types and another for the order). If my seller-name and
buyer-name complex types use the "type" attribute to specify my common Name
type, then the namespace of seller-name and buyer-name should be "order" and
not "common". If my complex types use the "ref" attribute to point to a Name
element in my common schema, then I cannot change the name of the element from
"name" to "buyer-name" and "seller-name". Please let me know if I am missing
something and there is a way to have Castor generate XML in such a way that I
can break out the schemas.
I am happy to reply back with the schema I would like to use but I did not want
to clutter up this initial email.
Thank you,
Josh
____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433