Discussion:
namespaces in castor-xml marshalling
Clearwater, Pete
2003-06-04 17:16:48 UTC
Permalink
Hi.

I'm trying to use the castor-xml package to generate a very basic xml representation of my java object, then take this xml output and run it through some xslt to generate html. The problem is that Castor seems to be putting in default namespaces (ns1,
ns2, ns3,...) whenever I use a mapping file. If I don't use a mapping file then Castor does not put in any namespace information (which is OK) but the default mappings do not work as I need them to. My example is quite large, but I'll give some
abbreviated text to show the problem:

from mapping file:

<class name="ubc.ems.core.awards.CyclicalAward" access="shared">
<description>Default mapping for class ubc.ems.core.awards.CyclicalAward</description>
<map-to xml="cyclical-award" ns-uri="http://students.ubc.ca" ns-prefix="ubcns"/>
<field name="minDistAmount" type="double">
<bind-xml name="min-dist-amount" node="element"/>
</field>
<field name="rollCycle" type="integer">
<bind-xml name="roll-cycle" node="element"/>
</field>
... plus more...

to do the mapping:

Mapping map = ch.getMapping(obj.getClass().getName());
StringWriter sw = new StringWriter();
BufferedWriter bw = new BufferedWriter(sw);
Marshaller mar = new Marshaller(bw);
mar.setMapping(map);
mar.marshal(obj);

output with mapping file:

<?xml version="1.0" encoding="UTF-8"?>
<ubcns:cyclical-award xmlns:ubcns="http://students.ubc.ca">
<ns1:min-dist-amount xmlns:ns1="http://castor.exolab.org/">100.0</ns1:min-dist-amount>
<ns2:roll-cycle xmlns:ns2="http://castor.exolab.org/">1</ns2:roll-cycle>
... and a whole lot more...


Anyways, if anyone can shed some light on this, it would be greatly appreciated. I've tried various marshaller.setNameSpaceMappings with virtually no effect.

thanks.

pete.

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Sebastian
2003-06-04 17:56:47 UTC
Permalink
I have the same problem, what I have done is add the following method to the
Marshaller class :

private boolean _ignoreUndeclaredNamespaces = false;

public void setIgnoreUndeclaredNamespaces(boolean
ignoreUndeclaredNamespaces) {
_ignoreUndeclaredNamespaces = ignoreUndeclaredNamespaces;
_namespaces.setIgnoreUndeclaredNamespaces(ignoreUndeclaredNamespaces);
}

public boolean getIgnoreUndeclaredNamespaces() {
return _ignoreUndeclaredNamespaces;
}

So the marshall code will be something like this :

FileWriter out = new FileWriter(file);

Marshaller marshaller = new Marshaller(out);
marshaller.setIgnoreUndeclaredNamespaces(true);
marshaller.marshal(form);

regards
Sebastian

----- Original Message -----
From: "Clearwater, Pete" <***@students.ubc.ca>
To: <castor-***@exolab.org>
Sent: Wednesday, June 04, 2003 2:16 PM
Subject: [castor-dev] namespaces in castor-xml marshalling
Post by Clearwater, Pete
Hi.
I'm trying to use the castor-xml package to generate a very basic xml
representation of my java object, then take this xml output and run it
through some xslt to generate html. The problem is that Castor seems to be
putting in default namespaces (ns1,
Post by Clearwater, Pete
ns2, ns3,...) whenever I use a mapping file. If I don't use a mapping
file then Castor does not put in any namespace information (which is OK) but
the default mappings do not work as I need them to. My example is quite
large, but I'll give some
Post by Clearwater, Pete
<class name="ubc.ems.core.awards.CyclicalAward" access="shared">
<description>Default mapping for class
ubc.ems.core.awards.CyclicalAward</description>
Post by Clearwater, Pete
<map-to xml="cyclical-award" ns-uri="http://students.ubc.ca" ns-prefix="ubcns"/>
<field name="minDistAmount" type="double">
<bind-xml name="min-dist-amount" node="element"/>
</field>
<field name="rollCycle" type="integer">
<bind-xml name="roll-cycle" node="element"/>
</field>
... plus more...
Mapping map = ch.getMapping(obj.getClass().getName());
StringWriter sw = new StringWriter();
BufferedWriter bw = new BufferedWriter(sw);
Marshaller mar = new Marshaller(bw);
mar.setMapping(map);
mar.marshal(obj);
<?xml version="1.0" encoding="UTF-8"?>
<ubcns:cyclical-award xmlns:ubcns="http://students.ubc.ca">
<ns1:min-dist-amount
xmlns:ns1="http://castor.exolab.org/">100.0</ns1:min-dist-amount>
Post by Clearwater, Pete
<ns2:roll-cycle xmlns:ns2="http://castor.exolab.org/">1</ns2:roll-cycle>
... and a whole lot more...
Anyways, if anyone can shed some light on this, it would be greatly
appreciated. I've tried various marshaller.setNameSpaceMappings with
virtually no effect.
Post by Clearwater, Pete
thanks.
pete.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Keith Visco
2003-06-04 19:02:06 UTC
Permalink
What does your complete mapping file look like. It seems like you've
declared a default namespace in your mapping file and Castor is using
that in your XML.

Just remove the default namespace: xmlns="" and you should be ok.

--Keith
Post by Clearwater, Pete
Hi.
I'm trying to use the castor-xml package to generate a very basic xml representation of my java object, then take this xml output and run it through some xslt to generate html. The problem is that Castor seems to be putting in default namespaces (ns1,
ns2, ns3,...) whenever I use a mapping file. If I don't use a mapping file then Castor does not put in any namespace information (which is OK) but the default mappings do not work as I need them to. My example is quite large, but I'll give some
<class name="ubc.ems.core.awards.CyclicalAward" access="shared">
<description>Default mapping for class ubc.ems.core.awards.CyclicalAward</description>
<map-to xml="cyclical-award" ns-uri="http://students.ubc.ca" ns-prefix="ubcns"/>
<field name="minDistAmount" type="double">
<bind-xml name="min-dist-amount" node="element"/>
</field>
<field name="rollCycle" type="integer">
<bind-xml name="roll-cycle" node="element"/>
</field>
... plus more...
Mapping map = ch.getMapping(obj.getClass().getName());
StringWriter sw = new StringWriter();
BufferedWriter bw = new BufferedWriter(sw);
Marshaller mar = new Marshaller(bw);
mar.setMapping(map);
mar.marshal(obj);
<?xml version="1.0" encoding="UTF-8"?>
<ubcns:cyclical-award xmlns:ubcns="http://students.ubc.ca">
<ns1:min-dist-amount xmlns:ns1="http://castor.exolab.org/">100.0</ns1:min-dist-amount>
<ns2:roll-cycle xmlns:ns2="http://castor.exolab.org/">1</ns2:roll-cycle>
... and a whole lot more...
Anyways, if anyone can shed some light on this, it would be greatly appreciated. I've tried various marshaller.setNameSpaceMappings with virtually no effect.
thanks.
pete.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Clearwater, Pete
2003-06-04 20:35:51 UTC
Permalink
Yup, that did it. when I removed xmlns="http://castor.exolab.org/" xmlns:cst="http://castor.exolab.org/" from my mapping tag everything works as expected.

It seems like other people are running into the same problem - Should the default behaviour of the mapping generation tool be to leave off the namespace declaration?

Thanks alot Keith.



-----Original Message-----
From: Keith Visco [mailto:***@intalio.com]
Sent: Wednesday, June 04, 2003 12:02 PM
To: castor-***@exolab.org
Subject: Re: [castor-dev] namespaces in castor-xml marshalling



What does your complete mapping file look like. It seems like you've
declared a default namespace in your mapping file and Castor is using
that in your XML.

Just remove the default namespace: xmlns="" and you should be ok.

--Keith
Post by Clearwater, Pete
Hi.
I'm trying to use the castor-xml package to generate a very basic xml representation of my java object, then take this xml output and run it through some xslt to generate html. The problem is that Castor seems to be putting in default namespaces (ns1,
ns2, ns3,...) whenever I use a mapping file. If I don't use a mapping file then Castor does not put in any namespace information (which is OK) but the default mappings do not work as I need them to. My example is quite large, but I'll give some
<class name="ubc.ems.core.awards.CyclicalAward" access="shared">
<description>Default mapping for class ubc.ems.core.awards.CyclicalAward</description>
<map-to xml="cyclical-award" ns-uri="http://students.ubc.ca" ns-prefix="ubcns"/>
<field name="minDistAmount" type="double">
<bind-xml name="min-dist-amount" node="element"/>
</field>
<field name="rollCycle" type="integer">
<bind-xml name="roll-cycle" node="element"/>
</field>
... plus more...
Mapping map = ch.getMapping(obj.getClass().getName());
StringWriter sw = new StringWriter();
BufferedWriter bw = new BufferedWriter(sw);
Marshaller mar = new Marshaller(bw);
mar.setMapping(map);
mar.marshal(obj);
<?xml version="1.0" encoding="UTF-8"?>
<ubcns:cyclical-award xmlns:ubcns="http://students.ubc.ca">
<ns1:min-dist-amount xmlns:ns1="http://castor.exolab.org/">100.0</ns1:min-dist-amount>
<ns2:roll-cycle xmlns:ns2="http://castor.exolab.org/">1</ns2:roll-cycle>
... and a whole lot more...
Anyways, if anyone can shed some light on this, it would be greatly appreciated. I've tried various marshaller.setNameSpaceMappings with virtually no effect.
thanks.
pete.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Keith Visco
2003-06-04 21:01:29 UTC
Permalink
Post by Clearwater, Pete
Yup, that did it. when I removed xmlns="http://castor.exolab.org/" xmlns:cst="http://castor.exolab.org/" from my mapping tag everything works as expected.
It seems like other people are running into the same problem - Should the default behaviour of the mapping generation tool be to leave off the namespace declaration?
Probably. I'll have to take a look into that. I think a quick change in
the XML mapping loader could resolve that by "ignoring" the default
namespace for the bind-xml/@name attributes. It should probably only
handle prefixed names, since the default namespace would apply to the
mapping schema itself and not necessary the document being mapped.


--Keith

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Syed Tanveer
2003-06-04 21:45:57 UTC
Permalink
Team,

I have 2 java objects Address and Phone.

Address contains

streetName1
streetName2
phone (Contains elemtns of Phone)
city
state
country

Phone contains

homeNumber
mobileNumber
workNumber
faxNumber

How would I define a Mapping XML to obtain one XML structure with combining fields from both Address and Phone objects?

<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>

<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>

Any help is greatly apprecitated,

Thanks,

Syed


---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
Syed Tanveer
2003-06-05 13:47:14 UTC
Permalink
Am looking for an immediate reply on this, any help is greatly appreciated.

Team,

I have 2 java objects Address and Phone.

Address contains

streetName1
streetName2
phone (Contains elemtns of Phone)
city
state
country

Phone contains

homeNumber
mobileNumber
workNumber
faxNumber

How would I define a Mapping XML to obtain one XML structure with combining fields from both Address and Phone objects?

<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>

<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>

Any help is greatly apprecitated,

Thanks,

Syed



---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
Dennis Sosnoski
2003-06-05 17:10:47 UTC
Permalink
You may want to look into JiBX (http://www.jibx.org) as an alternative,
since JiBX supports mapping XML to Java objects with different
structures. The current beta 1a handles this type of thing well. The
long-delayed but coming-soon beta 2 adds a host of new features. You can
get a quick overview of JiBX structure mapping in the article at
http://www-106.ibm.com/developerworks/java/library/x-databd4/index.html

- Dennis
*Am looking for an immediate reply on this, any help is greatly
appreciated.*
Team,
I have 2 java objects Address and Phone.
Address contains
* streetName1
* streetName2
* phone (Contains elemtns of Phone)
* city
* state
* country
Phone contains
* homeNumber
* mobileNumber
* workNumber
* faxNumber
How would I define a Mapping XML to obtain one XML structure with
combining fields from both Address and Phone objects?
<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>
<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>
Any help is greatly apprecitated,
Thanks,
Syed
------------------------------------------------------------------------
Do you Yahoo!?
The New Yahoo! Search
<http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com> -
Faster. Easier. Bingo.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Keith Visco
2003-06-05 18:20:40 UTC
Permalink
You could try JiBX if you wish, but Castor certainly handles your case.
Containers on the java side have been supported for quite a while now.
Please see my other posting.

--Keith
Post by Dennis Sosnoski
You may want to look into JiBX (http://www.jibx.org) as an alternative,
since JiBX supports mapping XML to Java objects with different
structures. The current beta 1a handles this type of thing well. The
long-delayed but coming-soon beta 2 adds a host of new features. You can
get a quick overview of JiBX structure mapping in the article at
http://www-106.ibm.com/developerworks/java/library/x-databd4/index.html
- Dennis
*Am looking for an immediate reply on this, any help is greatly
appreciated.*
Team,
I have 2 java objects Address and Phone.
Address contains
* streetName1
* streetName2
* phone (Contains elemtns of Phone)
* city
* state
* country
Phone contains
* homeNumber
* mobileNumber
* workNumber
* faxNumber
How would I define a Mapping XML to obtain one XML structure with
combining fields from both Address and Phone objects?
<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>
<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>
Any help is greatly apprecitated,
Thanks,
Syed
------------------------------------------------------------------------
Do you Yahoo!?
The New Yahoo! Search
<http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com> -
Faster. Easier. Bingo.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Dennis Sosnoski
2003-06-05 18:42:09 UTC
Permalink
Sorry, I knew you'd added some basic structure change support recently,
but since nobody had replied to his posting I assumed it wouldn't handle
the case he needed. I'm not sure what other posting you mean, though.

- Dennis
Post by Keith Visco
You could try JiBX if you wish, but Castor certainly handles your case.
Containers on the java side have been supported for quite a while now.
Please see my other posting.
--Keith
Post by Dennis Sosnoski
You may want to look into JiBX (http://www.jibx.org) as an alternative,
since JiBX supports mapping XML to Java objects with different
structures. The current beta 1a handles this type of thing well. The
long-delayed but coming-soon beta 2 adds a host of new features. You can
get a quick overview of JiBX structure mapping in the article at
http://www-106.ibm.com/developerworks/java/library/x-databd4/index.html
- Dennis
*Am looking for an immediate reply on this, any help is greatly
appreciated.*
Team,
I have 2 java objects Address and Phone.
Address contains
* streetName1
* streetName2
* phone (Contains elemtns of Phone)
* city
* state
* country
Phone contains
* homeNumber
* mobileNumber
* workNumber
* faxNumber
How would I define a Mapping XML to obtain one XML structure with
combining fields from both Address and Phone objects?
<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>
<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>
Any help is greatly apprecitated,
Thanks,
Syed
------------------------------------------------------------------------
Do you Yahoo!?
The New Yahoo! Search
<http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com> -
Faster. Easier. Bingo.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Dennis Sosnoski
2003-06-05 18:45:30 UTC
Permalink
Whoops, your emails got delivered out of order for me. I see the one you
mean now.

- Dennis
Post by Dennis Sosnoski
Sorry, I knew you'd added some basic structure change support recently,
but since nobody had replied to his posting I assumed it wouldn't handle
the case he needed. I'm not sure what other posting you mean, though.
- Dennis
Post by Keith Visco
You could try JiBX if you wish, but Castor certainly handles your case.
Containers on the java side have been supported for quite a while now.
Please see my other posting.
--Keith
Post by Dennis Sosnoski
You may want to look into JiBX (http://www.jibx.org) as an alternative,
since JiBX supports mapping XML to Java objects with different
structures. The current beta 1a handles this type of thing well. The
long-delayed but coming-soon beta 2 adds a host of new features. You can
get a quick overview of JiBX structure mapping in the article at
http://www-106.ibm.com/developerworks/java/library/x-databd4/index.html
- Dennis
*Am looking for an immediate reply on this, any help is greatly
appreciated.*
Team,
I have 2 java objects Address and Phone.
Address contains
* streetName1
* streetName2
* phone (Contains elemtns of Phone)
* city
* state
* country
Phone contains
* homeNumber
* mobileNumber
* workNumber
* faxNumber
How would I define a Mapping XML to obtain one XML structure with
combining fields from both Address and Phone objects?
<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>
<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>
Any help is greatly apprecitated,
Thanks,
Syed
------------------------------------------------------------------------
Do you Yahoo!?
The New Yahoo! Search
<http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com> -
Faster. Easier. Bingo.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Keith Visco
2003-06-05 19:26:04 UTC
Permalink
Hi Dennis,
Post by Dennis Sosnoski
Sorry, I knew you'd added some basic structure change support recently,
Actually "container object" support has been around for many versions
now...for at least a year and half or more. Container objects are
objects which appear in the object model, but not in the xml output..as
is the case with the Syed's request.

It's the "container element" support which has been added recently
(adding extra elements to the output). This has been added recently with
the location attribute, but it's not needed for what Syed wanted to do.
Post by Dennis Sosnoski
but since nobody had replied to his posting I assumed it wouldn't handle
the case he needed. I'm not sure what other posting you mean, though.
I hadn't replied yet because I was sleeping when the post was sent! And
then of course I have to handle all my work related e-mails and issues
before I can spend a moment on the castor list.

Cheers!

--Keith

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Dennis Sosnoski
2003-06-05 19:50:41 UTC
Permalink
Post by Keith Visco
Hi Dennis,
Post by Dennis Sosnoski
Sorry, I knew you'd added some basic structure change support recently,
Actually "container object" support has been around for many versions
now...for at least a year and half or more. Container objects are
objects which appear in the object model, but not in the xml output..as
is the case with the Syed's request.
It's the "container element" support which has been added recently
(adding extra elements to the output). This has been added recently with
the location attribute, but it's not needed for what Syed wanted to do.
I hadn't realized this support for container objects was present in
Castor. I don't see any description of it in even the latest
documentation on the Castor XML Mapping, so that's probably why I didn't
know it was there. ;-) You might want to update the docs to include this
feature.

- Dennis

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev

tek1
2003-06-05 16:26:24 UTC
Permalink
What does your mapping.xml file look like? CastorXML should automatically
handle objects that contain other embedded objects. Hopefully, one of the
CastorXML experts will chime in.
Post by Syed Tanveer
Am looking for an immediate reply on this, any help is greatly appreciated.
Team,
I have 2 java objects Address and Phone.
Address contains
* streetName1
* streetName2
* phone (Contains elemtns of Phone)
* city
* state
* country
Phone contains
* homeNumber
* mobileNumber
* workNumber
* faxNumber
How would I define a Mapping XML to obtain one XML structure with
combining fields from both Address and Phone objects?
<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>
<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>
Any help is greatly apprecitated,
Thanks,
Syed
Do you Yahoo!?
<http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com>The New
Yahoo! Search - Faster. Easier. Bingo.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Keith Visco
2003-06-05 18:18:55 UTC
Permalink
Just mark the phone as a container in your mapping file.

<field name="phone" type="Phone" container="true"/>

--Keith
Post by tek1
What does your mapping.xml file look like? CastorXML should automatically
handle objects that contain other embedded objects. Hopefully, one of the
CastorXML experts will chime in.
Post by Syed Tanveer
Am looking for an immediate reply on this, any help is greatly appreciated.
Team,
I have 2 java objects Address and Phone.
Address contains
* streetName1
* streetName2
* phone (Contains elemtns of Phone)
* city
* state
* country
Phone contains
* homeNumber
* mobileNumber
* workNumber
* faxNumber
How would I define a Mapping XML to obtain one XML structure with
combining fields from both Address and Phone objects?
<!-- POSSIBLE XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<phone>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</phone>
</address>
<!-- PREFERRED XML OUTPUT -->
<address>
<street-name1>washington dr</street-name1>
<street-name2>1330 Suite</street-name2>
<city>Springfield</city>
<state>IL</state>
<home-number>888 1111</home-number>
<work-number>888 2222</work-number>
</address>
Any help is greatly apprecitated,
Thanks,
Syed
Do you Yahoo!?
<http://us.rd.yahoo.com/search/mailsig/*http://search.yahoo.com>The New
Yahoo! Search - Faster. Easier. Bingo.
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
***@exolab.org with a subject of:
unsubscribe castor-dev
Loading...