Stephen,
The real issue I had turned out to be really stupid. In my mapping
file, I had reversed the field name and bind-xml name;
For example I had something like this:
<field name="name" type="string" >
<bind-xml name="WorldName" node="element"
location="defenseDesignDocument/planningContextHeader/world" />
</field>
<field name="name" type="string" >
<bind-xml name="PlanName" node="element"
location="defenseDesignDocument/planningContextHeader/OPLAN" />
When I really needed:
<field name="worldName" type="string" >
<bind-xml name="name" node="element"
location="defenseDesignDocument/planningContextHeader/world" />
</field>
<field name="planName" type="string" >
<bind-xml name="name" node="element"
location="defenseDesignDocument/planningContextHeader/OPLAN" />
I created my own unique variables in my java program and it runs fine.
Thanks,
Jason
-----Original Message-----
From: Stephen Bash [mailto:[EMAIL PROTECTED]
Sent: Monday, July 25, 2005 4:52 PM
To: [email protected]
Subject: Re: [castor-user] Issue using same field name in xml document
Jason-
I'm having a little trouble reproducing the behaviors you're seeing, but
there are two things I can think of: one, in your mapping file, are you
mapping the two elements <name> to different fields in the java class?
(Might be a stupid question, but just want to check) And two, I did
have problems back in 0.9.5.4 with having multiple nested elements with
the same name (Castor tried to set one of the fields twice and the other
one was never touched).
As I dig back in my mail archive, it turns out Keith started working on
fixing this problem for multiple namespaces, but differing XPaths was
left as a somewhat academic discussion. So I might recommend setting
the two <name> elements with different namespaces just as an experiment,
and if that works, then maybe you can argue for the change up the line
(that's hard though, I know), otherwise, AFAIK Castor can't really
handle that mapping -- though if the other person has an XML Schema s/he
is working from, perhaps using Castor's SourceGenerator might give you a
set of classes that work.
Keith - Do you want to pitch in anything on this topic? I haven't
really been tracking progress in Castor XML and "advanced" mappings, so
maybe I'm missing something.
Sorry I can't be of more help.
Stephen
Green, Jason M. wrote:
> Hey all,
> I have been supplied with an xml document that I HAVE to use.
> There is little chance that I will have the authority to tell the
> person to modify it. That being said I have hit a wall with the fact
> that he has nested wrapper elements and inside those are fields with
the same name.
> Is there a way around the error that I get with the mapping file. I
> get this error: Nested error:
> org.exolab.castor.mapping.MappingException: The field name appears
> twice in the descriptor for xml.plan.PlanData
>
> Here is the xml file (at least a portion to explain better):
> <MDADocument>
> <defenseDesignDocument>
> <planningContextHeader>
> <world>
> <worldId />
> * <name />*
> </world>
> <OPLAN>
> <planId>-6048061182588210068</planId>
> * <name*>OIF</name>
> </OPLAN>
> </planningContextHeader>
> </defenseDesignDocument>
> </MDADocument>
>
> What I have bolded is where the issue lies. I tried in my mapping
> file to at least bind to a different name, but that doesn't seem to
work.
>
> Any Ideas?
> Thanks
> Jason
>
>
>
> Jason Green
> Software Engineer
> Northrop Grumman MS
> [EMAIL PROTECTED]
> (540) 469-2407
>
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message
to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------