Here is the excerpt for this element from the XML-Schema:
<xsd:complexType name="Body_Type" abstract="true">
<xsd:sequence>
<xsd:any namespace="##any" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="applicationId" use="required"/>
</xsd:complexType>
and this is the mapping:
<!-- mapping for Message class -->
<class name="data.Message">
<map-to xml="DirectTaxMessage" ns-uri="urn:a:uri" ns-prefix="urn" />
<field name="header" type="data.Header" required="true">
<bind-xml name="Header" node="element" />
</field>
<field name="body" type="data.Body" required="true">
<bind-xml name="Body" node="element" />
</field>
</class>
by adding a "different" uri statement in the <map-to> element, i get that
uri as an attribute which is merely, what
i wanted:
<!-- mapping for Body class -->
<class name="data.Body">
<map-to xml="Body" ns-uri="urn:a:different:uri" ns-prefix="urn1" />
<field name="appId" type="java.lang.String">
<bind-xml name="applicationId" node="attribute" />
</field>
<field name="initialElements" type="data.InitialElements">
<bind-xml name="InitialElements" node="element" />
</field>
...
...
</class>
below line is the current result:
<urn1:Body xmlns:urn1="urn:a:different:uri" appId="ap_id">
Thanks
Spiros Papadopoulos
Werner Guttmann
<werner.guttmann@
gmx.net> To
[email protected]
07/04/2008 13:45 cc
Mail Size: 11112
Subject
Please respond to Re: [castor-user] Namespace
[EMAIL PROTECTED] questions
aus.org Entity
HSBC Greece - HMLG
[EMAIL PROTECTED] wrote:
> Hi Werner,
>
> Thank you very much for your prompt reply! It was indeed the omission of
> the
> ns-uri attribute inside the <map-to> element that was causing it. I was
> ignoring it for several elements..
>
> One additional question:
>
> I have read the http://www.castor.org/xml-mapping.html#5.-xsi:type part
> on the website.. How would you suggest one can achieve producing the
> following
> "Body" element when Marshalling, with two different namespace uris and
the
> xsi:type
> as attributes? I have read & noticed some things already by myself, but I
> am mainly
> asking this question in order to fully understand and gain control over
the
> way
> the below is produced. Here is the desired output:
>
> <urn1:Body xmlns:urn="urn:a:different:uri"
> xmlns:urn1="urn:a:uri" xsi:type="urn:DataBody_Type"
> applicationId="an_id">
Hmm, what would a possible XML schema (fragment) look like for this
element ? And what does your mapping file for this currently look like ?
Werner
>
> Thanks in advance &
> Best Regards
>
> Spiros Papadopoulos.
>
>
>
>
> Werner Guttmann
> <werner.guttmann@
> gmx.net>
To
> [email protected]
> 05/04/2008 12:20
cc
> Mail Size: 6814
>
Subject
> Please respond to Re: [castor-user] Namespace
> [EMAIL PROTECTED] questions
> aus.org
Entity
> HSBC Greece - HMLG
>
>
>
>
>
>
>
>
>
>
> Hi Spiros,
>
> What happens if you change the <map-to> element to
>
> <map-to xml="Address" ns-uri="gttp://castor.org/test" ns-prefix="urn" />
>
> Specifying just a namespace prefix does not make any sense at all
> without actually specifying the namespace for which the prefix shoul dbe
> used.
>
> Let me know whether this helps ....
>
> Werner
>
> [EMAIL PROTECTED] wrote:
>> Hi,
>>
>> I am using Castor for the first time and although i have managed to see
> it
>> working properly in my case when Marshalling to XML, i get some
>> small inconsistencies in my output file which i cannot yet see how to
>> configure.
>>
>> Consider the following example mapping for a class Address:
>>
>> <!-- mapping for class Address -->
>> <class name="data.Address">
>> <map-to xml="Address" ns-prefix="urn" />
>> <field name="lAddressT" type="java.lang.String">
>> <bind-xml name="lAddressT" node="attribute"/>
>> </field>
>> <field name="countryCode" type="java.lang.String">
>> <bind-xml name="CountryCode" node="element" />
>> </field>
>> <field name="addressF" type="java.lang.String">
>> <bind-xml name="AddressF" node="element"/>
>> </field>
>> <field name="addressS" collection="arraylist"
>> get-method="getAddressS" set-method="setAddressS">
>> <bind-xml name="AddressS" node="element" />
>> </field>
>> </class>
>>
>> here is the output:
>>
>> <urn:Address>
>> <CountryCode>GR</CountryCode>
>> <AddressF>Name</AddressF>
>> </urn:Address>
>>
>> I would like the CountryCode and all subelements for all my class
> mappings,
>> which actually do
>> not have a class mapping them selves in the mapping file, to also have
> the
>> ns-prefix "urn".
>> How do i achieve this?
>>
>> Thanks in advance
>>
>> Spiros Papadopoulos
>>
>> ************************************************************
>> HSBC Bank plc
>> Registered Office: 8 Canada Square, London E14 5HQ
>> Registered in England - Number 14259
>> Authorised and regulated by the Financial Services Authority
>> ************************************************************
>> <HTML><BODY><P><hr size=1></P>
>> <P><STRONG>
>> SAVE PAPER - THINK BEFORE YOU PRINT!
>>
>> This E-mail is confidential.
>>
>> It may also be legally privileged. If you are not the addressee you may
> not copy, forward, disclose or use any part of it. If you have received
> this message in error, please delete it and all copies from your system
and
> notify the sender immediately by return E-mail.
>> Internet communications cannot be guaranteed to be timely secure, error
> or virus-free. The sender does not accept liability for any errors or
> omissions.
>> </STRONG></P></BODY></HTML>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>> http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
>
>
>
> ************************************************************
> HSBC Bank plc
> Registered Office: 8 Canada Square, London E14 5HQ
> Registered in England - Number 14259
> Authorised and regulated by the Financial Services Authority
> ************************************************************
>
>
> ************************************************************
> HSBC Bank plc
> Registered Office: 8 Canada Square, London E14 5HQ
> Registered in England - Number 14259
> Authorised and regulated by the Financial Services Authority
> ************************************************************
>
>
> -----------------------------------------
> SAVE PAPER - THINK BEFORE YOU PRINT!
>
> This E-mail is confidential.
>
> It may also be legally privileged. If you are not the addressee you
> may not copy, forward, disclose or use any part of it. If you have
> received this message in error, please delete it and all copies
> from your system and notify the sender immediately by return
> E-mail.
>
> Internet communications cannot be guaranteed to be timely secure,
> error or virus-free. The sender does not accept liability for any
> errors or omissions.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
************************************************************
HSBC Bank plc
Registered Office: 8 Canada Square, London E14 5HQ
Registered in England - Number 14259
Authorised and regulated by the Financial Services Authority
************************************************************
<HTML><BODY><P><hr size=1></P>
<P><STRONG>
SAVE PAPER - THINK BEFORE YOU PRINT!
This E-mail is confidential.
It may also be legally privileged. If you are not the addressee you may not
copy, forward, disclose or use any part of it. If you have received this
message in error, please delete it and all copies from your system and notify
the sender immediately by return E-mail.
Internet communications cannot be guaranteed to be timely secure, error or
virus-free. The sender does not accept liability for any errors or omissions.
</STRONG></P></BODY></HTML>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email