Nigel,

See inline below...

Nigel Kibble wrote:
Hi,

I'm trying to use Castor to unmarshall XML purchase orders, via a number
of different scemas.

One of the complex elements contained within the purchase order is
"Party", containing name and address information. I'm expecting to
receive about four of these party elements within each PO; for buyer,
supplier, delivery point, etc.
Each party has a qualifier code ("role" attribute) such as
"DeliveryPoint". This qualifier code will vary across schemas, so I want
to adopt my own qualifier code within my bean that will be generic from
the schema (ie 1 for Delivery point). My questions are: 1) Can I do something within the XML mapper to convert a value of
"DeliveryPoint" to a value of say 1?  I'd obviously rather do this
within the mapper than within the bean.

You can write a custom FieldHandler to do this. You can attach a FieldHandler either via a mapping file or a binding file. For more information on custom FieldHandler's please see:

http://castor.codehaus.org/xml-fieldhandlers.html

2)  Do I HAVE to use a collection of Party objects within my
PurchaseOrder, or could I have 4 specific variables of buyerParty,
supplierParty, etc within my PurchaseOrder, and have some way of
populating these specific variables depending upon the value of the
"role" attribute?

You could write an "addParty(Party party)" method that simply assigned the party to proper field based on the value of the role.

This can also be done using the a custom field handler. Your custom field handler can call the appropriate setter method based on the role value.

--Keith


-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to