Hi Phong...
Currently our mapping framework cannot directly handle your situation.
Can you modify PathAssociation such that is has an addProperty method:
something like:
addProptery(Property property) {
if ("pathAssociationId".equals(property.getName())) {
setPathAssociationId(property);
}
else if (...) {
...
}
}
I know it's not ideal, but it would actually be more efficient than
using XSLT.
--Keith
Phong Vu wrote:
>
> Hi,
>
> I have an existing project where xml <-> java object conversion would
> be very helpful.
>
> The problem that I am having is that some legacy XML files that I have
> appear difficult for Castor to map into java objects. At least the XML
> formats are different from the examples given.
>
> I'm just wondering if the mapping can be specified in Castor or else
> I have do to some XSLT translation on the XML file before Castor can
> use it?
>
> Below is a simplified description of my problem.
>
> I would like the element with the attribute name "pathAssociation" to
> map to the class PathAssociation.
>
> Is this possible? If so what would the mapping.xml file look like?
>
> Any feedback would be greatly appreciated.
>
> /*listing for pathAssociation.xml**********************************/
>
> <?xml version="1.0" encoding="UTF-8"?>
> <aspect name="pathAssociation" sequence="1">
> <property name="pathAssociationId" type="string">1853</property>
> <property name="componentAgreementTypeId"
> type="string">652</property>
> </aspect>
>
> /**listing for PathAssociation.java *********************/
> class PathAssociation{
> Property pathAssociationId;
> Property componentAgreementTypeId;
>
> public void setPathAssociationId(Property value){
> ...
> }
> public void setComponentAgreementTypeId(Property value){
> ...
> }
>
> public Property getPathAssociationId(){
> ...
> }
> public Property getComponentAgreementTypeId(){
> ...
> }
>
> }
>
> /**************listing for Property.java *****************************/
> class Property{
> String name;
> String type;
>
> public void setName(String value){
> ...
> }
> public void setType(String value){
> ...
> }
>
> public String getName(){
> ...
> }
> public String getType(){
> ...
> }
>
> }
>
>
> ___________________________________________________________
> FREE voicemail, email and fax, all in one place. Sign Up Now! http://www.mybc.com
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev