xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Vasilik" <eric...@bea.com>
Subject RE: get/set methods for <xsd:any> element
Date Wed, 07 Jan 2004 05:52:51 GMT
If you want to insert an existing XmlObject, then you would first
position a cursor at the desired destination position (as I showed
before), then you would create another XmlCursor from the source
XmlObject and then call moveXml or copyXml on the source cursor, passing
as an argument, the target cursor.

If, however, you do not have a source XmlObject, but just want to
construct some XML at a given position, say
<anything1><anything2/></anything1>, you could position a cursor to
where you want to insert the new XML and:

    cursor.beginElement( "anything1" );
    cursor.insertElement( "anything2" );

Hope this helps,
Eric
    

-----Original Message-----
From: Ganga Sah [mailto:ganga_sah@yahoo.com] 
Sent: Monday, January 05, 2004 11:05 PM
To: xmlbeans-dev@xml.apache.org
Subject: RE: get/set methods for <xsd:any> element

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/


- ---------------------------------------------------------------------
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