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


Reply via email to