Thanks for responding.
Actually, my class would look something like:

public class MyDocument {
    // other fields
    private String myNode;
    private String myNodeAttr1;
    private String myNodeAttr2;
    private String myOtherNode;
    private String myOtherNodeAttr1;
    private String myOtherNodeAttr2;
    private String myStillOtherNode;
    private String myStillOtherNodeAttr1;
    private String myStillOtherNodeAttr2;
    // other fields
}

and the input/output xml would look like:

<MyDocument>
    <!-- other simpler elements -->
    <myNode myAttr1="value1" myAttr2="value2">My Node's Value</myNode>
    <myOtherNode myAttr1="value1" myAttr2="value2">My Other Node's
Value</myNode>
    <myStillOtherNode myAttr1="value1" myAttr2="value2">Still My Other
Node's Value</myNode>
    <!-- other simpler elements -->
</MyDocument>

Thanks,
 Hubert


On Tue, 12 Oct 2004 13:06:04 -0700 (PDT), Hector Huang
<[EMAIL PROTECTED]> wrote:
> 
> Assuming your class is:
> 
> public class MyNode {
> 
>  private String myAttr1;
>  private String myAttr2;
>  private String value;
> 
>  // ...default constructor + getters and setters
> }
> 
> is this what you are looking for?
> 
>   <class name="MyNode">
> 
>        <map-to xml="myNode"/>
> 
>        <field name="MyAttr1" type="string">
>          <bind-xml name="myAttr1" node="attribute"/>
>        </field>
> 
>        <field name="MyAttr2" type="string">
>          <bind-xml name="myAttr2" node="attribute"/>
>        </field>
> 
>        <field name="Value" type="string">
>            <bind-xml node="text"/>
>        </field>
>    </class>
> 
> 
> 
> --- Hubert Rabago <[EMAIL PROTECTED]> wrote:
> 
> >
> > Hi,
> >
> > I'm having a difficult time trying to map an element
> > like this:
> >
> > <myNode myAttr1="value1" myAttr2="value2">My Node's
> > Value</myNode>
> >
> > My java object has fields for myNode, myAttr1, and
> > myAttr2.  I have
> > some flexibility in changing the object, and have
> > even tried creating
> > an inner class that will allow me to move the
> > mapping into another
> > <class> defintion, but either I did something wrong
> > or Castor won't
> > work with inner classes.
> >
> > I have several elements like this, with both nodes
> > and attributes, and
> > in general I would like to avoid creating new
> > classes just for them
> > (or I'd go from five classes to about sixty).
> >
> > I tried the "location" attribute as well but it will
> > only work if I
> > don't want/need the actual value of the element
> > itself, which I do.
> >
> > Can anyone point me to what I can do or a doc I can
> > consult for this
> > situation?  I had a hard time looking for the
> > answers in the castor
> > docs, the mailing archives, and google.
> >
> > TIA,
> >
> > Hubert
> >



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to