Discussion:
[castor-dev] Unmarshalling with different namespaces
AJO
2012-05-15 16:20:47 UTC
Permalink
Hi,

I can't get unmarshalling to work with a combination of default namespace
and specific namespace.

The passed xml is the following:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<clc:CalculationOutput
xmlns:clc="http://aaa.bbb.cc/ns/Calc/CalculInOut/CalcElement"
xmlns="http://www.example.org/example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<clc:RuntimeConfiguration id="ID:a6db6635" name="runtime1" version="0.3"/>
<clc:Calculation>
<field1 ref="S442">
<Features>
<ID>28</ID>
<year>2011</year>
<quarter>1</quarter>
<amount>216187.23</amount>
</Features>
</field1>
</clc:Calculation>
</clc:CalculationOutput>


I can only get the above xml to get unmarshalled by adding xmlns="" to the
ID, year, quarter and amount fields, so it seems the default schema is never
taken into account.

How can I get the above mapped in castor, taking into account the default
schema?

This is the mapping file working when I add xmlns="" to the detail fields:
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.org/mapping.dtd">
<!--mapping xmlns:clc="http://aaa.bbb.cc/ns/Calc/CalculInOut/CalcElement"
xmlns="http://www.example.org/field1"
xsi:schemaLocation="C:/resources/schema/schemalocation.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"-->
<mapping>

<class name="entity.CalculationOutput" >
<map-to xml="CalculationOutput" ns-prefix="clc"/>

<field name="versie" type="entity.output.CalculatorVersie">
<bind-xml name="RuntimeConfiguration"/>
</field>

<field name="field1" type="entity.output.CalculatorBw">
<bind-xml name="field1" location="Calculation"/>
</field>
</class>


<class name="entity.output.CalculatorBw">
<map-to xml="field1" ns-prefix=""/>

<field name="id" type="string">
<bind-xml name="ref" node="attribute"/>
</field>

<field name="number" type="string">
<bind-xml name="ID" node="element" location="Features"/>
</field>

<field name="year" type="string">
<bind-xml name="year" node="element" location="Features"/>
</field>

<field name="quarter" type="string">
<bind-xml name="quarter" node="element" location="Features"/>
</field>

<field name="amount" type="string">
<bind-xml name="amount" node="element" location="Features"/>
</field>
</class>
--
View this message in context: http://old.nabble.com/Unmarshalling-with-different-namespaces-tp33848928p33848928.html
Sent from the Castor - Dev mailing list archive at Nabble.com.


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

http://xircles.codehaus.org/manage_email
Werner Guttmann
2012-05-16 07:45:59 UTC
Permalink
Hi,

switching this conversation to the user list, as that's where it should
take place.

For answers to your questions, please see inline.

Kind Regards
Werner
Post by AJO
Hi,
I can't get unmarshalling to work with a combination of default namespace
and specific namespace.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<clc:CalculationOutput
xmlns:clc="http://aaa.bbb.cc/ns/Calc/CalculInOut/CalcElement"
xmlns="http://www.example.org/example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<clc:RuntimeConfiguration id="ID:a6db6635" name="runtime1" version="0.3"/>
<clc:Calculation>
<field1 ref="S442">
<Features>
<ID>28</ID>
<year>2011</year>
<quarter>1</quarter>
<amount>216187.23</amount>
</Features>
</field1>
</clc:Calculation>
</clc:CalculationOutput>
I can only get the above xml to get unmarshalled by adding xmlns="" to the
ID, year, quarter and amount fields, so it seems the default schema is never
taken into account.
How can I get the above mapped in castor, taking into account the default
schema?
<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.org/mapping.dtd">
<!--mapping xmlns:clc="http://aaa.bbb.cc/ns/Calc/CalculInOut/CalcElement"
xmlns="http://www.example.org/field1"
xsi:schemaLocation="C:/resources/schema/schemalocation.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"-->
<mapping>
<class name="entity.CalculationOutput">
<map-to xml="CalculationOutput" ns-prefix="clc"/>
You still need to define the namespace URI to which you want this (and
all other classes, of course) class to be bound:

<class name="entity.CalculationOutput">
<map-to xml="CalculationOutput"
ns-uri="http://aaa.bbb.cc/ns/Calc/CalculInOut/CalcElement"
ns-prefix="clc"/>

Can you please add those bindings accordingly, and everything should be set.
Post by AJO
<field name="versie" type="entity.output.CalculatorVersie">
<bind-xml name="RuntimeConfiguration"/>
</field>
<field name="field1" type="entity.output.CalculatorBw">
<bind-xml name="field1" location="Calculation"/>
</field>
</class>
<class name="entity.output.CalculatorBw">
<map-to xml="field1" ns-prefix=""/>
<field name="id" type="string">
<bind-xml name="ref" node="attribute"/>
</field>
<field name="number" type="string">
<bind-xml name="ID" node="element" location="Features"/>
</field>
<field name="year" type="string">
<bind-xml name="year" node="element" location="Features"/>
</field>
<field name="quarter" type="string">
<bind-xml name="quarter" node="element" location="Features"/>
</field>
<field name="amount" type="string">
<bind-xml name="amount" node="element" location="Features"/>
</field>
</class>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Loading...