Thank you for your reply,
I did the following for class tags I added
<map-to xml="xx" ns-prefix="prefix"/>
and for fields with datatypes such as String I did the following
<field name="Message"
type="java.lang.String">
<bind-xml name="Message" node="element">
<class name="java.lang.String">
<map-to ns-prefix="prefix"/>
</class>
</bind-xml>
</field>
That works.
Thank you
Werner Guttmann-6 wrote:
>
> Hi,
>
> why don't you declare the namespace prefix on all elements (which is
> what is required anyhow) ? Just imagine a situation where you'd need
> more than one namespace/prefix. How would you handle this situation when
> namespaces/prefixes are carried over ?
>
> Regards
> Werner
>
> On 15.11.2010 14:55, kkrikor wrote:
>>
>> Hey guys,
>>
>> I am setting a ns-prefix on my parent element but it is not carrying over
>> to
>> the child elements. I am setting the configuration in my mapping.xml as
>> such
>>
>> <mapping>
>> <class name="org.test.Container">
>> <map-to xml="rls" ns-prefix="rls"/>
>>
>> <field name="collection1"
>> type="org.test.Object1"
>> collection="arraylist">
>> <bind-xml name="assignment"/>
>> </field>
>>
>> <field name="collection2"
>> type="org.test.Object2"
>> collection="arraylist">
>> <bind-xml name="definition"/>
>> </field>
>> </class>
>>
>> <class name="org.test.Object1">
>>
>> <field name="Target"
>> type="org.test.ObjectXBean">
>> <bind-xml name="Target"/>
>> </field>
>> ......
>>
>> </class>
>> .......
>> </mapping>
>>
>> When castor generates the XML i get the following
>>
>> <rls:rls>
>> <assignment>
>> <Target>...</Target>
>> </assignment>
>> </rls:rls>
>>
>> I am expecting :
>>
>> <rls:rls>
>> <rls:assignment>
>> <rls:Target>...</rls:Target>
>> </rls:assignment>
>> </rls:rls>
>>
>>
>> Here is the marshalling code:
>>
>> Mapping mapping = new Mapping();
>>
>> mapping.loadMapping(getCoreResources().getURL("mapping.xml"));
>> // Create XMLContext
>> XMLContext xmlContext = new XMLContext();
>> xmlContext.setProperty(XMLConfiguration.NAMESPACES, "true");
>> xmlContext.addMapping(mapping);
>>
>> StringWriter writer = new StringWriter();
>> Marshaller marshaller = xmlContext.createMarshaller();
>> marshaller.setWriter(writer);
>> marshaller.marshal(obj);
>>
>> Am i missing anything ?
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
>
--
View this message in context:
http://old.nabble.com/ns-prefix-not-applied-on-all-child-elements-tp30219095p30248770.html
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email