xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ganga Sah <ganga_...@yahoo.com>
Subject RE: get/set methods for <xsd:any> element
Date Tue, 06 Jan 2004 07:04:51 GMT
Hi Eric,
Thanks for your reply.
I want to start with XML instance
"<foo><bar>xyx</bar></foo>", and insert an
XmlObject(say, "<anything1><anything2/></anything1>"
corresponding to xsd:any element) as the first child
of FooType object to get say,
"<foo><anything1><anything2/></anything1><bar>xyx</bar></foo>".
I am unable to do this using XmlCursor API, as
XmlCursor.insertElement()/beginElement() methods does
not take XmlObject as parameter but take only simple
element(string)??
How can I insert XmlObject into an existing XML
content tree?
thanks,
ganga

--- Eric Vasilik <ericvas@bea.com> wrote:
> Given an XmlObject (all user generated objects
> derive from this), you
> can call newCursor().  This will return an XmlCursor
> which is positioned
> at the element or attribute associated with the
> XmlObject.
> 
> Thus, in your case, from FooType, you could:
> 
>     FooType ft = ....;
>     XmlCursor c = ft.newCursor(); // Cursor is at
> <foo>
>     c.toFirstChild();             // Cursor is at
> <a:bbbb>
>     c.toNextSibling();            // Cursor it at
> <bar>
>     etc ...
> 
> You can transition back to XmlObject from an
> XmlCursor by calling
> getObject() on the cursor.  If this object has a
> java type, you will be
> able to cast it appropriately.  
> 
> Does this help?
> 
> - Eric
> 
> -----Original Message-----
> From: Ganga Sah [mailto:ganga_sah@yahoo.com] 
> Sent: Monday, January 05, 2004 12:01 PM
> To: xmlbeans-dev@xml.apache.org
> Subject: RE: get/set methods for <xsd:any> element
> 
> Hi Eric,
> My schema has following pattern:
> <schema ..>
> <element name="foo" type="FooType"/>
> 
> <xsd:complexType name="extType">
>  <xsd:sequence>
>   <xsd:any minOccurs="0" maxOccurs="unbounded"
> namespace="##other"/>           
>  </xsd:sequence>
> </xsd:complexType>
> 
> <xsd:complexType name="FooType">
>  <xsd:complexContent>
>   <xsd:extension base="extType">         
>    <xsd:sequence>
>     <xsd:element name="bar" type="xsd:string" />
>    </xsd:sequence>
>    </xsd:extension>
>   </xsd:complexContent>                	
> </xsd:complexType>
> </schema>
> 
> Correspong xml-fragment is:
> 
> <foo>
>   <a:bbbb xmlns:a="aaaa">
>   <bar>some-content</bar>
> </foo>
> 
> I have got content of this XML instance in FooType
> Java object.
> How can I use xmlCursor to get(or set) the
> un-named(xsd:any) element(first child of FooType
> here)?
> Could you help me by giving me a code snippet to do
> this?
> 
> thanks a lot,
> ganga
> 
> 
> 
> 
> --- Eric Vasilik <ericvas@bea.com> wrote:
> > We do not generate methods for the any elements. 
> > However, you can use XmlCursor to navigate this
> > content in an un-typed manner.
> > 
> > -----Original Message-----
> > From: Ganga Sah [mailto:ganga_sah@yahoo.com]
> > Sent: Monday, January 05, 2004 9:47 AM
> > To: xmlbeans-dev@xml.apache.org
> > Subject: get/set methods for <xsd:any> element
> > 
> > 
> > I am unable to find/use get(set) methods in
> xmlbeans
> > generated Java code for <xsd:any> element?
> > 
> > -ganga
> > 
> > __________________________________
> > Do you Yahoo!?
> > Find out what made the Top Yahoo! Searches of 2003
> > http://search.yahoo.com/top2003
> > 
> > -
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:  
> > xmlbeans-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail:
> > xmlbeans-dev-help@xml.apache.org
> > Apache XMLBeans Project -- URL:
> > http://xml.apache.org/xmlbeans/
> > 
> > 
> > -
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:  
> > xmlbeans-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail:
> > xmlbeans-dev-help@xml.apache.org
> > Apache XMLBeans Project -- URL:
> > http://xml.apache.org/xmlbeans/
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Find out what made the Top Yahoo! Searches of 2003
> http://search.yahoo.com/top2003
> 
> -
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> xmlbeans-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xmlbeans-dev-help@xml.apache.org
> Apache XMLBeans Project -- URL:
> http://xml.apache.org/xmlbeans/
> 
> 
> -
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> xmlbeans-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xmlbeans-dev-help@xml.apache.org
> Apache XMLBeans Project -- URL:
> http://xml.apache.org/xmlbeans/
> 


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message