Problem in marshalling elements (sending request)

View: New views
2 Messages — Rating Filter:   Alert me  

Problem in marshalling elements (sending request)

by Westhveg () :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm using castor 1.3 and Spring. I have a problem with marshalling, let me explain with some code:

This is my class configuration in mapping.xml file:

<class name="com.mypackage.MyClass">
        <map-to xml="myXmlElementA" ns-uri="http://mynamespaceuri/" ns-prefix="tns" />

        <field name="value" type="java.lang.String" required="true">
                <bind-xml name="myXmlElementB" node="element" />
        </field>
</class>

And this is the resulting XML when it sends the request:

<tns:myXmlElementA xmlns:tns="http://mynamespaceuri/">
        <tns:myXmlElementB>Input Value</tns:myXmlElementB>
</tns:myXmlElementA>


But I need this:

<tns:myXmlElementA xmlns:tns="http://mynamespaceuri/">
        <myXmlElementB>Input Value</myXmlElementB>
</tns:myXmlElementA>


How can I remove the 'tns' prefix from 'myXmlElementB'?


Thanks in advance,

Westhveg

Re: Problem in marshalling elements (sending request)

by Werner Guttmann-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

that's difficult to answer, to be honest, as qualification is not
straight-forward.

Let me first ask a question myself: do you have an XML schema for that
XML document instance you are showing below ? If so, what's the
elementFormDefault attribute set to ?

Regards
Werner

Westhveg wrote:

> Hello,
>
> I'm using castor 1.3. I have a problem with marshalling, let me explain with
> some code:
>
> This is my class configuration in mapping.xml file:
>
> <class name="com.mypackage.MyClass">
> <map-to xml="myXmlElementA" ns-uri="http://mynamespaceuri/" ns-prefix="tns"
> />
>
> <field name="value" type="java.lang.String" required="true">
> <bind-xml name="myXmlElementB" node="element" />
> </field>
> </class>
>
> And this is the resulting XML when it sends the request:
>
> <tns:myXmlElementA xmlns:tns="http://mynamespaceuri/">
> <tns:myXmlElementB>Input Value</tns:myXmlElementB>
> </tns:myXmlElementA>
>
>
> But I need this:
>
> <tns:myXmlElementA xmlns:tns="http://mynamespaceuri/">
> <myXmlElementB>Input Value</myXmlElementB>
> </tns:myXmlElementA>
>
>
> How can I remove the 'tns' prefix from 'myXmlElementB'?
>
>
> Thanks in advance,
>
> Westhveg

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

    http://xircles.codehaus.org/manage_email