You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Desmond Whewell (CV/ETL)" <de...@ericsson.com> on 2007/06/20 11:39:10 UTC

Getting concrete object from Any

Sorry about Yet-Another-Any question, but this is my first expedition in
Xmlbeans and I have seached the documentation and Javadocs and I'm still
banging my head against a brick wall.

Suppose I have a schema with an element, 'myElem', say. One of the child
elements, 'myChild', is defined as:

    <xs:element name="myChild" type="MyChildType" minOccurs="0" />
    <xs:complexType name="MyChildType">
        <xs:sequence>
	      <xs:any namespace="##any" processContents="lax"
maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

I can get at MyChild by:

    MyChildType myChild = myElem.getMyChild();

But, and you all know what's coming, how do I get the object that is
*actually* being carried in the place of the Any? I have tried using
XmlCursors to navigate to the object, but I really don't want to have to
disassemble the XmlObject, what I really want is to get back to the cosy
world of gets and sets on the concrete objects.

So, if I had a xml fragement that looked like:

    <myElem>
        <daughter>britney spears</daughter>
    </myElem>

What is the cleanest way of extracting the XmlObject and creating the
associated 'daughter' xmlbean so that I can go back to :

	daughter.getAge();

Assume that 'daughter' is the only element type that I'm prepared to
accept and that other elements will be rejected by the surrounding
application as 'not supported'.

Thanks for any help.

Cheers, Des

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by "Vinh Nguyen (vinguye2)" <vi...@cisco.com>.
Thanks Radu,
I'll definitely take a look!
-Vinh

-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radup@bea.com] 
Sent: Friday, June 22, 2007 4:57 PM
To: user@xmlbeans.apache.org
Subject: RE: Getting concrete object from Any

Thanks, that is fine though, that type is extremely generic so yeah, no
specific methods are generated at all.

We have some sample code that shows how to deal with <any> in XmlBeans,
I am not sure if everybody is aware of that:

 http://xmlbeans.apache.org/samples/Any.html

Radu

On Fri, 2007-06-22 at 16:26 -0700, Vinh Nguyen (vinguye2) wrote:
> Hi Radu,
> Attached are the enumeration wsdls.  In case it gets blocked, below is

> a small snippet.  I am using XmlBeans 2.2.0, and it doesn't generate 
> the proper get/set methods for the xs:any in EnumerationContextType.
> Perhaps there's other syntax in the type or file definition that might

> be causing the problem, but I can't tell since I don't know all the 
> xsd syntax recognized by XmlBeans.
> 
> <xs:schema
xmlns:tns="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
> 
> xmlns:wsa="http://www.w3.org/2005/08/addressing"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://schemas.xmlsoap.org/ws/2004/09/enumeration" 
> elementFormDefault="qualified" blockDefault="#all">
> 
> 	<xs:complexType name="EnumerationContextType" mixed="true">
> 		<xs:complexContent mixed="true">
> 			<xs:restriction base="xs:anyType">
> 				<xs:sequence>
> 					<xs:any namespace="##other"
> processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
> 				</xs:sequence>
> 				<xs:anyAttribute namespace="##other"
> processContents="lax"/>
> 			</xs:restriction>
> 		</xs:complexContent>
> 	</xs:complexType>
> 
> 
> -----Original Message-----
> From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
> Sent: Friday, June 22, 2007 4:19 PM
> To: user@xmlbeans.apache.org
> Subject: RE: Getting concrete object from Any
> 
> That is a little surprising to me. Could you attach a Schema that 
> exemplifies these points?
> 
> Radu
> 
> On Fri, 2007-06-22 at 15:26 -0700, Vinh Nguyen (vinguye2) wrote:
> > As a note, set(XmlObject) will exist in the generated type if using 
> > the first xs:any definition below.  But, this method is actually 
> > from the base XmlObject, and it expects the same object type as the 
> > parent...not
> > *any* type of object.
> > 
> > 
> > 
> > -----Original Message-----
> > From: Vinh Nguyen (vinguye2)
> > Sent: Friday, June 22, 2007 3:23 PM
> > To: user@xmlbeans.apache.org
> > Subject: RE: Getting concrete object from Any
> > 
> > I had the same question awhile back when generating from the 
> > WS-Enumeration-2004_09.wsdl available on the web.  The problem was 
> > this
> > definition:
> > 
> > <xs:any namespace="##any" processContents="lax" 
> > maxOccurs="unbounded"/>
> > 
> > XmlBeans doesn't seem to handle this type of syntax properly, so it 
> > doesn't generate the proper get/set methods for this object.  But, 
> > if I define it as the following, then the methods are generated
properly:
> > 
> > <xs:any maxOccurs="unbounded"/>
> > 
> > I haven't been able to find an easy way around this and stick to the

> > schema, without modifying the standard wsdl.
> > 
> > 
> > -----Original Message-----
> > From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
> > Sent: Friday, June 22, 2007 2:33 PM
> > To: user@xmlbeans.apache.org
> > Subject: RE: Getting concrete object from Any
> > 
> > My opinion is that it will just work even if you have multiple jars,

> > must be something else that complicates David's case (substitution 
> > groups).
> > 
> > However, Desmond, it seems to me that what you suggest is exactly 
> > what
> 
> > XmlBeans is doing today. Note that in your Schema, the <any> 
> > wildcard is a child of the <myChild> element, so obviously you can't

> > replace <myChild> with <daughter>, but you need to have <daughter> 
> > as a child,
> 
> > like so:
> > 
> > <myElem>
> >   <myChild>
> >     <daughter>britney spears</daughter>
> >   </myChild>
> > </myElem>
> > 
> > Or, you need to change your Schema.
> > 
> > Now if you do
> > 
> > MyChildType myChild = myElem.getMyChild(); XmlObject instance = 
> > myChild.selectChildren("", "daughter")[0];
> > 
> > you will see that "instance" already has the right type.
> > 
> > Radu
> > 
> > On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> > > David,
> > > 
> > > Thank you for your help. Mercifully, my schemas *are* compiled in 
> > > one pass and *do* end up in 1 jar file. I tried this:
> > > 
> > >     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
> > >     Daughter daughter = null;
> > >     for (int i = 0; i < objs.length; i++) {
> > >         XmlObject myObj =  objs[i];
> > >                 
> > >         daughter =
> > (Daughter)Daughter.Factory.newInstance().set(myObj);
> > >         break;
> > >     }
> > >     if (daughter != null) {
> > >         int j = daughter.getAge();        
> > >     .....etc.....
> > > 
> > > or something very similar, and it worked!
> > > 
> > > As an xmlbeans newbie, I think the manipulation of 'Any's could be

> > > made easier. It's a pity I couldn't have done something like:
> > > 
> > >     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
> > >     if (daughter != null) {
> > >     .....etc.....
> > > 
> > > After all, doesn't xmlbeans already have all of the information 
> > > required to extract the concrete from the Any?
> > > 
> > > Thanks again,
> > > 
> > > Des
> > > 
> > > -----Original Message-----
> > > From: David Jencks [mailto:david_jencks@yahoo.com]
> > > Sent: 20 June 2007 12:56
> > > To: user@xmlbeans.apache.org
> > > Subject: Re: Getting concrete object from Any
> > > 
> > > 1. IIUC your sample document should look like <myElem 
> > > xmlns="mine"> <myChlid> <daughter>foo</daughter> </myChild> 
> > > </myElem>
> > > 
> > > 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> > > 
> > > If all your schemas are compiled at once into one jar I think this

> > > will return the desired XmlObjects as the types you expect.   
> > > Otherwise if you get a plain XmlObject you may have to copy and 
> > > call
> > > changeType(desiredSchemaType) on them.  When I do this I find that

> > > trying to call changeType without making a new copy usually 
> > > doesn't work, but I'm also trying to glue together a lot of schema

> > > type systems from several jars, so it may work better if all your 
> > > schemas
> 
> > > are compiled at once.
> > > 
> > > hope this helps
> > > david jencks
> > > 
> > > On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> > > 
> > > > Sorry about Yet-Another-Any question, but this is my first 
> > > > expedition in Xmlbeans and I have seached the documentation and 
> > > > Javadocs and I'm still banging my head against a brick wall.
> > > >
> > > > Suppose I have a schema with an element, 'myElem', say. One of 
> > > > the
> 
> > > > child elements, 'myChild', is defined as:
> > > >
> > > >     <xs:element name="myChild" type="MyChildType" minOccurs="0"
/>
> > > >     <xs:complexType name="MyChildType">
> > > >         <xs:sequence>
> > > > 	      <xs:any namespace="##any" processContents="lax"
> > > > maxOccurs="unbounded" />
> > > >         </xs:sequence>
> > > >     </xs:complexType>
> > > >
> > > > I can get at MyChild by:
> > > >
> > > >     MyChildType myChild = myElem.getMyChild();
> > > >
> > > > But, and you all know what's coming, how do I get the object 
> > > > that is
> > > > *actually* being carried in the place of the Any? I have tried 
> > > > using
> > 
> > > > XmlCursors to navigate to the object, but I really don't want to

> > > > have to disassemble the XmlObject, what I really want is to get 
> > > > back
> > 
> > > > to the
> > > 
> > > > cosy world of gets and sets on the concrete objects.
> > > >
> > > > So, if I had a xml fragement that looked like:
> > > >
> > > >     <myElem>
> > > >         <daughter>britney spears</daughter>
> > > >     </myElem>
> > > >
> > > > What is the cleanest way of extracting the XmlObject and 
> > > > creating the associated 'daughter' xmlbean so that I can go back
to :
> > > >
> > > > 	daughter.getAge();
> > > >
> > > > Assume that 'daughter' is the only element type that I'm 
> > > > prepared to
> > 
> > > > accept and that other elements will be rejected by the 
> > > > surrounding
> 
> > > > application as 'not supported'.
> > > >
> > > > Thanks for any help.
> > > >
> > > > Cheers, Des
> > > >
> > > > ----------------------------------------------------------------
> > > > --
> > > > --
> > > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > > >
> > > 
> > > 
> > > ------------------------------------------------------------------
> > > --
> > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > > 
> > > 
> > > ------------------------------------------------------------------
> > > --
> > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > > 
> > 
> > Notice:  This email message, together with any attachments, may 
> > contain information  of  BEA Systems,  Inc.,  its subsidiaries  and 
> > affiliated entities,  that may be confidential,  proprietary, 
> > copyrighted  and/or legally privileged, and is intended solely for 
> > the
> 
> > use of the individual or entity named in this message. If you are 
> > not the intended recipient, and have received this message in error,

> > please immediately return this by email and then delete it.
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> 
> Notice:  This email message, together with any attachments, may 
> contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  
> affiliated entities,  that may be confidential,  proprietary,  
> copyrighted  and/or legally privileged, and is intended solely for the

> use of the individual or entity named in this message. If you are not 
> the intended recipient, and have received this message in error, 
> please immediately return this by email and then delete it.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
Thanks, that is fine though, that type is extremely generic so yeah, no
specific methods are generated at all.

We have some sample code that shows how to deal with <any> in XmlBeans,
I am not sure if everybody is aware of that:

 http://xmlbeans.apache.org/samples/Any.html

Radu

On Fri, 2007-06-22 at 16:26 -0700, Vinh Nguyen (vinguye2) wrote:
> Hi Radu,
> Attached are the enumeration wsdls.  In case it gets blocked, below is a
> small snippet.  I am using XmlBeans 2.2.0, and it doesn't generate the
> proper get/set methods for the xs:any in EnumerationContextType.
> Perhaps there's other syntax in the type or file definition that might
> be causing the problem, but I can't tell since I don't know all the xsd
> syntax recognized by XmlBeans.
> 
> <xs:schema xmlns:tns="http://schemas.xmlsoap.org/ws/2004/09/enumeration"
> 
> xmlns:wsa="http://www.w3.org/2005/08/addressing"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://schemas.xmlsoap.org/ws/2004/09/enumeration" 
> elementFormDefault="qualified" blockDefault="#all">
> 
> 	<xs:complexType name="EnumerationContextType" mixed="true">
> 		<xs:complexContent mixed="true">
> 			<xs:restriction base="xs:anyType">
> 				<xs:sequence>
> 					<xs:any namespace="##other"
> processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
> 				</xs:sequence>
> 				<xs:anyAttribute namespace="##other"
> processContents="lax"/>
> 			</xs:restriction>
> 		</xs:complexContent>
> 	</xs:complexType> 
> 
> 
> -----Original Message-----
> From: Radu Preotiuc-Pietro [mailto:radup@bea.com] 
> Sent: Friday, June 22, 2007 4:19 PM
> To: user@xmlbeans.apache.org
> Subject: RE: Getting concrete object from Any
> 
> That is a little surprising to me. Could you attach a Schema that
> exemplifies these points?
> 
> Radu
> 
> On Fri, 2007-06-22 at 15:26 -0700, Vinh Nguyen (vinguye2) wrote:
> > As a note, set(XmlObject) will exist in the generated type if using 
> > the first xs:any definition below.  But, this method is actually from 
> > the base XmlObject, and it expects the same object type as the 
> > parent...not
> > *any* type of object.
> > 
> > 
> > 
> > -----Original Message-----
> > From: Vinh Nguyen (vinguye2)
> > Sent: Friday, June 22, 2007 3:23 PM
> > To: user@xmlbeans.apache.org
> > Subject: RE: Getting concrete object from Any
> > 
> > I had the same question awhile back when generating from the 
> > WS-Enumeration-2004_09.wsdl available on the web.  The problem was 
> > this
> > definition:
> > 
> > <xs:any namespace="##any" processContents="lax" 
> > maxOccurs="unbounded"/>
> > 
> > XmlBeans doesn't seem to handle this type of syntax properly, so it 
> > doesn't generate the proper get/set methods for this object.  But, if 
> > I define it as the following, then the methods are generated properly:
> > 
> > <xs:any maxOccurs="unbounded"/>
> > 
> > I haven't been able to find an easy way around this and stick to the 
> > schema, without modifying the standard wsdl.
> > 
> > 
> > -----Original Message-----
> > From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
> > Sent: Friday, June 22, 2007 2:33 PM
> > To: user@xmlbeans.apache.org
> > Subject: RE: Getting concrete object from Any
> > 
> > My opinion is that it will just work even if you have multiple jars, 
> > must be something else that complicates David's case (substitution 
> > groups).
> > 
> > However, Desmond, it seems to me that what you suggest is exactly what
> 
> > XmlBeans is doing today. Note that in your Schema, the <any> wildcard 
> > is a child of the <myChild> element, so obviously you can't replace 
> > <myChild> with <daughter>, but you need to have <daughter> as a child,
> 
> > like so:
> > 
> > <myElem>
> >   <myChild>
> >     <daughter>britney spears</daughter>
> >   </myChild>
> > </myElem>
> > 
> > Or, you need to change your Schema.
> > 
> > Now if you do
> > 
> > MyChildType myChild = myElem.getMyChild(); XmlObject instance = 
> > myChild.selectChildren("", "daughter")[0];
> > 
> > you will see that "instance" already has the right type.
> > 
> > Radu
> > 
> > On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> > > David,
> > > 
> > > Thank you for your help. Mercifully, my schemas *are* compiled in 
> > > one pass and *do* end up in 1 jar file. I tried this:
> > > 
> > >     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
> > >     Daughter daughter = null;
> > >     for (int i = 0; i < objs.length; i++) {
> > >         XmlObject myObj =  objs[i];
> > >                 
> > >         daughter =
> > (Daughter)Daughter.Factory.newInstance().set(myObj);
> > >         break;
> > >     }
> > >     if (daughter != null) {
> > >         int j = daughter.getAge();        
> > >     .....etc.....
> > > 
> > > or something very similar, and it worked!
> > > 
> > > As an xmlbeans newbie, I think the manipulation of 'Any's could be 
> > > made easier. It's a pity I couldn't have done something like:
> > > 
> > >     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
> > >     if (daughter != null) {
> > >     .....etc.....
> > > 
> > > After all, doesn't xmlbeans already have all of the information 
> > > required to extract the concrete from the Any?
> > > 
> > > Thanks again,
> > > 
> > > Des
> > > 
> > > -----Original Message-----
> > > From: David Jencks [mailto:david_jencks@yahoo.com]
> > > Sent: 20 June 2007 12:56
> > > To: user@xmlbeans.apache.org
> > > Subject: Re: Getting concrete object from Any
> > > 
> > > 1. IIUC your sample document should look like <myElem xmlns="mine"> 
> > > <myChlid> <daughter>foo</daughter> </myChild> </myElem>
> > > 
> > > 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> > > 
> > > If all your schemas are compiled at once into one jar I think this  
> > > will return the desired XmlObjects as the types you expect.   
> > > Otherwise if you get a plain XmlObject you may have to copy and call
> > > changeType(desiredSchemaType) on them.  When I do this I find that 
> > > trying to call changeType without making a new copy usually doesn't 
> > > work, but I'm also trying to glue together a lot of schema type 
> > > systems from several jars, so it may work better if all your schemas
> 
> > > are compiled at once.
> > > 
> > > hope this helps
> > > david jencks
> > > 
> > > On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> > > 
> > > > Sorry about Yet-Another-Any question, but this is my first 
> > > > expedition in Xmlbeans and I have seached the documentation and 
> > > > Javadocs and I'm still banging my head against a brick wall.
> > > >
> > > > Suppose I have a schema with an element, 'myElem', say. One of the
> 
> > > > child elements, 'myChild', is defined as:
> > > >
> > > >     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
> > > >     <xs:complexType name="MyChildType">
> > > >         <xs:sequence>
> > > > 	      <xs:any namespace="##any" processContents="lax"
> > > > maxOccurs="unbounded" />
> > > >         </xs:sequence>
> > > >     </xs:complexType>
> > > >
> > > > I can get at MyChild by:
> > > >
> > > >     MyChildType myChild = myElem.getMyChild();
> > > >
> > > > But, and you all know what's coming, how do I get the object that 
> > > > is
> > > > *actually* being carried in the place of the Any? I have tried 
> > > > using
> > 
> > > > XmlCursors to navigate to the object, but I really don't want to 
> > > > have to disassemble the XmlObject, what I really want is to get 
> > > > back
> > 
> > > > to the
> > > 
> > > > cosy world of gets and sets on the concrete objects.
> > > >
> > > > So, if I had a xml fragement that looked like:
> > > >
> > > >     <myElem>
> > > >         <daughter>britney spears</daughter>
> > > >     </myElem>
> > > >
> > > > What is the cleanest way of extracting the XmlObject and creating 
> > > > the associated 'daughter' xmlbean so that I can go back to :
> > > >
> > > > 	daughter.getAge();
> > > >
> > > > Assume that 'daughter' is the only element type that I'm prepared 
> > > > to
> > 
> > > > accept and that other elements will be rejected by the surrounding
> 
> > > > application as 'not supported'.
> > > >
> > > > Thanks for any help.
> > > >
> > > > Cheers, Des
> > > >
> > > > ------------------------------------------------------------------
> > > > --
> > > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > > >
> > > 
> > > 
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > > 
> > > 
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > > 
> > 
> > Notice:  This email message, together with any attachments, may 
> > contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  
> > affiliated entities,  that may be confidential,  proprietary,  
> > copyrighted  and/or legally privileged, and is intended solely for the
> 
> > use of the individual or entity named in this message. If you are not 
> > the intended recipient, and have received this message in error, 
> > please immediately return this by email and then delete it.
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> 
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by "Vinh Nguyen (vinguye2)" <vi...@cisco.com>.
Hi Radu,
Attached are the enumeration wsdls.  In case it gets blocked, below is a
small snippet.  I am using XmlBeans 2.2.0, and it doesn't generate the
proper get/set methods for the xs:any in EnumerationContextType.
Perhaps there's other syntax in the type or file definition that might
be causing the problem, but I can't tell since I don't know all the xsd
syntax recognized by XmlBeans.

<xs:schema xmlns:tns="http://schemas.xmlsoap.org/ws/2004/09/enumeration"

xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.xmlsoap.org/ws/2004/09/enumeration" 
elementFormDefault="qualified" blockDefault="#all">

	<xs:complexType name="EnumerationContextType" mixed="true">
		<xs:complexContent mixed="true">
			<xs:restriction base="xs:anyType">
				<xs:sequence>
					<xs:any namespace="##other"
processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
				</xs:sequence>
				<xs:anyAttribute namespace="##other"
processContents="lax"/>
			</xs:restriction>
		</xs:complexContent>
	</xs:complexType> 


-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radup@bea.com] 
Sent: Friday, June 22, 2007 4:19 PM
To: user@xmlbeans.apache.org
Subject: RE: Getting concrete object from Any

That is a little surprising to me. Could you attach a Schema that
exemplifies these points?

Radu

On Fri, 2007-06-22 at 15:26 -0700, Vinh Nguyen (vinguye2) wrote:
> As a note, set(XmlObject) will exist in the generated type if using 
> the first xs:any definition below.  But, this method is actually from 
> the base XmlObject, and it expects the same object type as the 
> parent...not
> *any* type of object.
> 
> 
> 
> -----Original Message-----
> From: Vinh Nguyen (vinguye2)
> Sent: Friday, June 22, 2007 3:23 PM
> To: user@xmlbeans.apache.org
> Subject: RE: Getting concrete object from Any
> 
> I had the same question awhile back when generating from the 
> WS-Enumeration-2004_09.wsdl available on the web.  The problem was 
> this
> definition:
> 
> <xs:any namespace="##any" processContents="lax" 
> maxOccurs="unbounded"/>
> 
> XmlBeans doesn't seem to handle this type of syntax properly, so it 
> doesn't generate the proper get/set methods for this object.  But, if 
> I define it as the following, then the methods are generated properly:
> 
> <xs:any maxOccurs="unbounded"/>
> 
> I haven't been able to find an easy way around this and stick to the 
> schema, without modifying the standard wsdl.
> 
> 
> -----Original Message-----
> From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
> Sent: Friday, June 22, 2007 2:33 PM
> To: user@xmlbeans.apache.org
> Subject: RE: Getting concrete object from Any
> 
> My opinion is that it will just work even if you have multiple jars, 
> must be something else that complicates David's case (substitution 
> groups).
> 
> However, Desmond, it seems to me that what you suggest is exactly what

> XmlBeans is doing today. Note that in your Schema, the <any> wildcard 
> is a child of the <myChild> element, so obviously you can't replace 
> <myChild> with <daughter>, but you need to have <daughter> as a child,

> like so:
> 
> <myElem>
>   <myChild>
>     <daughter>britney spears</daughter>
>   </myChild>
> </myElem>
> 
> Or, you need to change your Schema.
> 
> Now if you do
> 
> MyChildType myChild = myElem.getMyChild(); XmlObject instance = 
> myChild.selectChildren("", "daughter")[0];
> 
> you will see that "instance" already has the right type.
> 
> Radu
> 
> On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> > David,
> > 
> > Thank you for your help. Mercifully, my schemas *are* compiled in 
> > one pass and *do* end up in 1 jar file. I tried this:
> > 
> >     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
> >     Daughter daughter = null;
> >     for (int i = 0; i < objs.length; i++) {
> >         XmlObject myObj =  objs[i];
> >                 
> >         daughter =
> (Daughter)Daughter.Factory.newInstance().set(myObj);
> >         break;
> >     }
> >     if (daughter != null) {
> >         int j = daughter.getAge();        
> >     .....etc.....
> > 
> > or something very similar, and it worked!
> > 
> > As an xmlbeans newbie, I think the manipulation of 'Any's could be 
> > made easier. It's a pity I couldn't have done something like:
> > 
> >     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
> >     if (daughter != null) {
> >     .....etc.....
> > 
> > After all, doesn't xmlbeans already have all of the information 
> > required to extract the concrete from the Any?
> > 
> > Thanks again,
> > 
> > Des
> > 
> > -----Original Message-----
> > From: David Jencks [mailto:david_jencks@yahoo.com]
> > Sent: 20 June 2007 12:56
> > To: user@xmlbeans.apache.org
> > Subject: Re: Getting concrete object from Any
> > 
> > 1. IIUC your sample document should look like <myElem xmlns="mine"> 
> > <myChlid> <daughter>foo</daughter> </myChild> </myElem>
> > 
> > 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> > 
> > If all your schemas are compiled at once into one jar I think this  
> > will return the desired XmlObjects as the types you expect.   
> > Otherwise if you get a plain XmlObject you may have to copy and call
> > changeType(desiredSchemaType) on them.  When I do this I find that 
> > trying to call changeType without making a new copy usually doesn't 
> > work, but I'm also trying to glue together a lot of schema type 
> > systems from several jars, so it may work better if all your schemas

> > are compiled at once.
> > 
> > hope this helps
> > david jencks
> > 
> > On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> > 
> > > Sorry about Yet-Another-Any question, but this is my first 
> > > expedition in Xmlbeans and I have seached the documentation and 
> > > Javadocs and I'm still banging my head against a brick wall.
> > >
> > > Suppose I have a schema with an element, 'myElem', say. One of the

> > > child elements, 'myChild', is defined as:
> > >
> > >     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
> > >     <xs:complexType name="MyChildType">
> > >         <xs:sequence>
> > > 	      <xs:any namespace="##any" processContents="lax"
> > > maxOccurs="unbounded" />
> > >         </xs:sequence>
> > >     </xs:complexType>
> > >
> > > I can get at MyChild by:
> > >
> > >     MyChildType myChild = myElem.getMyChild();
> > >
> > > But, and you all know what's coming, how do I get the object that 
> > > is
> > > *actually* being carried in the place of the Any? I have tried 
> > > using
> 
> > > XmlCursors to navigate to the object, but I really don't want to 
> > > have to disassemble the XmlObject, what I really want is to get 
> > > back
> 
> > > to the
> > 
> > > cosy world of gets and sets on the concrete objects.
> > >
> > > So, if I had a xml fragement that looked like:
> > >
> > >     <myElem>
> > >         <daughter>britney spears</daughter>
> > >     </myElem>
> > >
> > > What is the cleanest way of extracting the XmlObject and creating 
> > > the associated 'daughter' xmlbean so that I can go back to :
> > >
> > > 	daughter.getAge();
> > >
> > > Assume that 'daughter' is the only element type that I'm prepared 
> > > to
> 
> > > accept and that other elements will be rejected by the surrounding

> > > application as 'not supported'.
> > >
> > > Thanks for any help.
> > >
> > > Cheers, Des
> > >
> > > ------------------------------------------------------------------
> > > --
> > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > >
> > 
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> > 
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> 
> Notice:  This email message, together with any attachments, may 
> contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  
> affiliated entities,  that may be confidential,  proprietary,  
> copyrighted  and/or legally privileged, and is intended solely for the

> use of the individual or entity named in this message. If you are not 
> the intended recipient, and have received this message in error, 
> please immediately return this by email and then delete it.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

RE: Getting concrete object from Any

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
That is a little surprising to me. Could you attach a Schema that
exemplifies these points?

Radu

On Fri, 2007-06-22 at 15:26 -0700, Vinh Nguyen (vinguye2) wrote:
> As a note, set(XmlObject) will exist in the generated type if using the
> first xs:any definition below.  But, this method is actually from the
> base XmlObject, and it expects the same object type as the parent...not
> *any* type of object.
> 
> 
> 
> -----Original Message-----
> From: Vinh Nguyen (vinguye2) 
> Sent: Friday, June 22, 2007 3:23 PM
> To: user@xmlbeans.apache.org
> Subject: RE: Getting concrete object from Any
> 
> I had the same question awhile back when generating from the
> WS-Enumeration-2004_09.wsdl available on the web.  The problem was this
> definition:
> 
> <xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>
> 
> XmlBeans doesn't seem to handle this type of syntax properly, so it
> doesn't generate the proper get/set methods for this object.  But, if I
> define it as the following, then the methods are generated properly:
> 
> <xs:any maxOccurs="unbounded"/>
> 
> I haven't been able to find an easy way around this and stick to the
> schema, without modifying the standard wsdl.
> 
> 
> -----Original Message-----
> From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
> Sent: Friday, June 22, 2007 2:33 PM
> To: user@xmlbeans.apache.org
> Subject: RE: Getting concrete object from Any
> 
> My opinion is that it will just work even if you have multiple jars,
> must be something else that complicates David's case (substitution
> groups).
> 
> However, Desmond, it seems to me that what you suggest is exactly what
> XmlBeans is doing today. Note that in your Schema, the <any> wildcard is
> a child of the <myChild> element, so obviously you can't replace
> <myChild> with <daughter>, but you need to have <daughter> as a child,
> like so:
> 
> <myElem>
>   <myChild>
>     <daughter>britney spears</daughter>
>   </myChild>
> </myElem>
> 
> Or, you need to change your Schema.
> 
> Now if you do
> 
> MyChildType myChild = myElem.getMyChild(); XmlObject instance =
> myChild.selectChildren("", "daughter")[0];
> 
> you will see that "instance" already has the right type.
> 
> Radu
> 
> On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> > David,
> > 
> > Thank you for your help. Mercifully, my schemas *are* compiled in one 
> > pass and *do* end up in 1 jar file. I tried this:
> > 
> >     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
> >     Daughter daughter = null;
> >     for (int i = 0; i < objs.length; i++) {
> >         XmlObject myObj =  objs[i];
> >                 
> >         daughter =
> (Daughter)Daughter.Factory.newInstance().set(myObj);
> >         break;
> >     }
> >     if (daughter != null) {
> >         int j = daughter.getAge();        
> >     .....etc.....
> > 
> > or something very similar, and it worked!
> > 
> > As an xmlbeans newbie, I think the manipulation of 'Any's could be 
> > made easier. It's a pity I couldn't have done something like:
> > 
> >     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
> >     if (daughter != null) {
> >     .....etc.....
> > 
> > After all, doesn't xmlbeans already have all of the information 
> > required to extract the concrete from the Any?
> > 
> > Thanks again,
> > 
> > Des
> > 
> > -----Original Message-----
> > From: David Jencks [mailto:david_jencks@yahoo.com]
> > Sent: 20 June 2007 12:56
> > To: user@xmlbeans.apache.org
> > Subject: Re: Getting concrete object from Any
> > 
> > 1. IIUC your sample document should look like <myElem xmlns="mine"> 
> > <myChlid> <daughter>foo</daughter> </myChild> </myElem>
> > 
> > 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> > 
> > If all your schemas are compiled at once into one jar I think this  
> > will return the desired XmlObjects as the types you expect.   
> > Otherwise if you get a plain XmlObject you may have to copy and call
> > changeType(desiredSchemaType) on them.  When I do this I find that 
> > trying to call changeType without making a new copy usually doesn't 
> > work, but I'm also trying to glue together a lot of schema type 
> > systems from several jars, so it may work better if all your schemas 
> > are compiled at once.
> > 
> > hope this helps
> > david jencks
> > 
> > On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> > 
> > > Sorry about Yet-Another-Any question, but this is my first 
> > > expedition in Xmlbeans and I have seached the documentation and 
> > > Javadocs and I'm still banging my head against a brick wall.
> > >
> > > Suppose I have a schema with an element, 'myElem', say. One of the 
> > > child elements, 'myChild', is defined as:
> > >
> > >     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
> > >     <xs:complexType name="MyChildType">
> > >         <xs:sequence>
> > > 	      <xs:any namespace="##any" processContents="lax"
> > > maxOccurs="unbounded" />
> > >         </xs:sequence>
> > >     </xs:complexType>
> > >
> > > I can get at MyChild by:
> > >
> > >     MyChildType myChild = myElem.getMyChild();
> > >
> > > But, and you all know what's coming, how do I get the object that is
> > > *actually* being carried in the place of the Any? I have tried using
> 
> > > XmlCursors to navigate to the object, but I really don't want to 
> > > have to disassemble the XmlObject, what I really want is to get back
> 
> > > to the
> > 
> > > cosy world of gets and sets on the concrete objects.
> > >
> > > So, if I had a xml fragement that looked like:
> > >
> > >     <myElem>
> > >         <daughter>britney spears</daughter>
> > >     </myElem>
> > >
> > > What is the cleanest way of extracting the XmlObject and creating 
> > > the associated 'daughter' xmlbean so that I can go back to :
> > >
> > > 	daughter.getAge();
> > >
> > > Assume that 'daughter' is the only element type that I'm prepared to
> 
> > > accept and that other elements will be rejected by the surrounding 
> > > application as 'not supported'.
> > >
> > > Thanks for any help.
> > >
> > > Cheers, Des
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > >
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> > 
> 
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by "Vinh Nguyen (vinguye2)" <vi...@cisco.com>.
As a note, set(XmlObject) will exist in the generated type if using the
first xs:any definition below.  But, this method is actually from the
base XmlObject, and it expects the same object type as the parent...not
*any* type of object.



-----Original Message-----
From: Vinh Nguyen (vinguye2) 
Sent: Friday, June 22, 2007 3:23 PM
To: user@xmlbeans.apache.org
Subject: RE: Getting concrete object from Any

I had the same question awhile back when generating from the
WS-Enumeration-2004_09.wsdl available on the web.  The problem was this
definition:

<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>

XmlBeans doesn't seem to handle this type of syntax properly, so it
doesn't generate the proper get/set methods for this object.  But, if I
define it as the following, then the methods are generated properly:

<xs:any maxOccurs="unbounded"/>

I haven't been able to find an easy way around this and stick to the
schema, without modifying the standard wsdl.


-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radup@bea.com]
Sent: Friday, June 22, 2007 2:33 PM
To: user@xmlbeans.apache.org
Subject: RE: Getting concrete object from Any

My opinion is that it will just work even if you have multiple jars,
must be something else that complicates David's case (substitution
groups).

However, Desmond, it seems to me that what you suggest is exactly what
XmlBeans is doing today. Note that in your Schema, the <any> wildcard is
a child of the <myChild> element, so obviously you can't replace
<myChild> with <daughter>, but you need to have <daughter> as a child,
like so:

<myElem>
  <myChild>
    <daughter>britney spears</daughter>
  </myChild>
</myElem>

Or, you need to change your Schema.

Now if you do

MyChildType myChild = myElem.getMyChild(); XmlObject instance =
myChild.selectChildren("", "daughter")[0];

you will see that "instance" already has the right type.

Radu

On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> David,
> 
> Thank you for your help. Mercifully, my schemas *are* compiled in one 
> pass and *do* end up in 1 jar file. I tried this:
> 
>     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
>     Daughter daughter = null;
>     for (int i = 0; i < objs.length; i++) {
>         XmlObject myObj =  objs[i];
>                 
>         daughter =
(Daughter)Daughter.Factory.newInstance().set(myObj);
>         break;
>     }
>     if (daughter != null) {
>         int j = daughter.getAge();        
>     .....etc.....
> 
> or something very similar, and it worked!
> 
> As an xmlbeans newbie, I think the manipulation of 'Any's could be 
> made easier. It's a pity I couldn't have done something like:
> 
>     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
>     if (daughter != null) {
>     .....etc.....
> 
> After all, doesn't xmlbeans already have all of the information 
> required to extract the concrete from the Any?
> 
> Thanks again,
> 
> Des
> 
> -----Original Message-----
> From: David Jencks [mailto:david_jencks@yahoo.com]
> Sent: 20 June 2007 12:56
> To: user@xmlbeans.apache.org
> Subject: Re: Getting concrete object from Any
> 
> 1. IIUC your sample document should look like <myElem xmlns="mine"> 
> <myChlid> <daughter>foo</daughter> </myChild> </myElem>
> 
> 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> 
> If all your schemas are compiled at once into one jar I think this  
> will return the desired XmlObjects as the types you expect.   
> Otherwise if you get a plain XmlObject you may have to copy and call
> changeType(desiredSchemaType) on them.  When I do this I find that 
> trying to call changeType without making a new copy usually doesn't 
> work, but I'm also trying to glue together a lot of schema type 
> systems from several jars, so it may work better if all your schemas 
> are compiled at once.
> 
> hope this helps
> david jencks
> 
> On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> 
> > Sorry about Yet-Another-Any question, but this is my first 
> > expedition in Xmlbeans and I have seached the documentation and 
> > Javadocs and I'm still banging my head against a brick wall.
> >
> > Suppose I have a schema with an element, 'myElem', say. One of the 
> > child elements, 'myChild', is defined as:
> >
> >     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
> >     <xs:complexType name="MyChildType">
> >         <xs:sequence>
> > 	      <xs:any namespace="##any" processContents="lax"
> > maxOccurs="unbounded" />
> >         </xs:sequence>
> >     </xs:complexType>
> >
> > I can get at MyChild by:
> >
> >     MyChildType myChild = myElem.getMyChild();
> >
> > But, and you all know what's coming, how do I get the object that is
> > *actually* being carried in the place of the Any? I have tried using

> > XmlCursors to navigate to the object, but I really don't want to 
> > have to disassemble the XmlObject, what I really want is to get back

> > to the
> 
> > cosy world of gets and sets on the concrete objects.
> >
> > So, if I had a xml fragement that looked like:
> >
> >     <myElem>
> >         <daughter>britney spears</daughter>
> >     </myElem>
> >
> > What is the cleanest way of extracting the XmlObject and creating 
> > the associated 'daughter' xmlbean so that I can go back to :
> >
> > 	daughter.getAge();
> >
> > Assume that 'daughter' is the only element type that I'm prepared to

> > accept and that other elements will be rejected by the surrounding 
> > application as 'not supported'.
> >
> > Thanks for any help.
> >
> > Cheers, Des
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by "Vinh Nguyen (vinguye2)" <vi...@cisco.com>.
I had the same question awhile back when generating from the
WS-Enumeration-2004_09.wsdl available on the web.  The problem was this
definition:

<xs:any namespace="##any" processContents="lax" maxOccurs="unbounded"/>

XmlBeans doesn't seem to handle this type of syntax properly, so it
doesn't generate the proper get/set methods for this object.  But, if I
define it as the following, then the methods are generated properly:

<xs:any maxOccurs="unbounded"/>

I haven't been able to find an easy way around this and stick to the
schema, without modifying the standard wsdl.


-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radup@bea.com] 
Sent: Friday, June 22, 2007 2:33 PM
To: user@xmlbeans.apache.org
Subject: RE: Getting concrete object from Any

My opinion is that it will just work even if you have multiple jars,
must be something else that complicates David's case (substitution
groups).

However, Desmond, it seems to me that what you suggest is exactly what
XmlBeans is doing today. Note that in your Schema, the <any> wildcard is
a child of the <myChild> element, so obviously you can't replace
<myChild> with <daughter>, but you need to have <daughter> as a child,
like so:

<myElem>
  <myChild>
    <daughter>britney spears</daughter>
  </myChild>
</myElem>

Or, you need to change your Schema.

Now if you do

MyChildType myChild = myElem.getMyChild(); XmlObject instance =
myChild.selectChildren("", "daughter")[0];

you will see that "instance" already has the right type.

Radu

On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> David,
> 
> Thank you for your help. Mercifully, my schemas *are* compiled in one 
> pass and *do* end up in 1 jar file. I tried this:
> 
>     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
>     Daughter daughter = null;
>     for (int i = 0; i < objs.length; i++) {
>         XmlObject myObj =  objs[i];
>                 
>         daughter =
(Daughter)Daughter.Factory.newInstance().set(myObj);
>         break;
>     }
>     if (daughter != null) {
>         int j = daughter.getAge();        
>     .....etc.....
> 
> or something very similar, and it worked!
> 
> As an xmlbeans newbie, I think the manipulation of 'Any's could be 
> made easier. It's a pity I couldn't have done something like:
> 
>     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
>     if (daughter != null) {
>     .....etc.....
> 
> After all, doesn't xmlbeans already have all of the information 
> required to extract the concrete from the Any?
> 
> Thanks again,
> 
> Des
> 
> -----Original Message-----
> From: David Jencks [mailto:david_jencks@yahoo.com]
> Sent: 20 June 2007 12:56
> To: user@xmlbeans.apache.org
> Subject: Re: Getting concrete object from Any
> 
> 1. IIUC your sample document should look like <myElem xmlns="mine"> 
> <myChlid> <daughter>foo</daughter> </myChild> </myElem>
> 
> 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> 
> If all your schemas are compiled at once into one jar I think this  
> will return the desired XmlObjects as the types you expect.   
> Otherwise if you get a plain XmlObject you may have to copy and call
> changeType(desiredSchemaType) on them.  When I do this I find that 
> trying to call changeType without making a new copy usually doesn't 
> work, but I'm also trying to glue together a lot of schema type 
> systems from several jars, so it may work better if all your schemas 
> are compiled at once.
> 
> hope this helps
> david jencks
> 
> On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> 
> > Sorry about Yet-Another-Any question, but this is my first 
> > expedition in Xmlbeans and I have seached the documentation and 
> > Javadocs and I'm still banging my head against a brick wall.
> >
> > Suppose I have a schema with an element, 'myElem', say. One of the 
> > child elements, 'myChild', is defined as:
> >
> >     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
> >     <xs:complexType name="MyChildType">
> >         <xs:sequence>
> > 	      <xs:any namespace="##any" processContents="lax"
> > maxOccurs="unbounded" />
> >         </xs:sequence>
> >     </xs:complexType>
> >
> > I can get at MyChild by:
> >
> >     MyChildType myChild = myElem.getMyChild();
> >
> > But, and you all know what's coming, how do I get the object that is
> > *actually* being carried in the place of the Any? I have tried using

> > XmlCursors to navigate to the object, but I really don't want to 
> > have to disassemble the XmlObject, what I really want is to get back

> > to the
> 
> > cosy world of gets and sets on the concrete objects.
> >
> > So, if I had a xml fragement that looked like:
> >
> >     <myElem>
> >         <daughter>britney spears</daughter>
> >     </myElem>
> >
> > What is the cleanest way of extracting the XmlObject and creating 
> > the associated 'daughter' xmlbean so that I can go back to :
> >
> > 	daughter.getAge();
> >
> > Assume that 'daughter' is the only element type that I'm prepared to

> > accept and that other elements will be rejected by the surrounding 
> > application as 'not supported'.
> >
> > Thanks for any help.
> >
> > Cheers, Des
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by "Desmond Whewell (CV/ETL)" <de...@ericsson.com>.
Radu,

Thanks for your comments. To complicate matters, I believe I ran into
the issue affecting xmlbeans when executing within Axis2, namely the
class loader problem
(http://issues.apache.org/jira/browse/XMLBEANS-310). My code worked fine
isolated in a Junit test, but fell apart on the server.

You are quite correct about the xml hierarchy and your code snippet
below looks sufficiently succinct for me.

Cheers, Des



-----Original Message-----
From: Radu Preotiuc-Pietro [mailto:radup@bea.com] 
Sent: 22 June 2007 22:33
To: user@xmlbeans.apache.org
Subject: RE: Getting concrete object from Any

My opinion is that it will just work even if you have multiple jars,
must be something else that complicates David's case (substitution
groups).

However, Desmond, it seems to me that what you suggest is exactly what
XmlBeans is doing today. Note that in your Schema, the <any> wildcard is
a child of the <myChild> element, so obviously you can't replace
<myChild> with <daughter>, but you need to have <daughter> as a child,
like so:

<myElem>
  <myChild>
    <daughter>britney spears</daughter>
  </myChild>
</myElem>

Or, you need to change your Schema.

Now if you do

MyChildType myChild = myElem.getMyChild(); XmlObject instance =
myChild.selectChildren("", "daughter")[0];

you will see that "instance" already has the right type.

Radu

On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> David,
> 
> Thank you for your help. Mercifully, my schemas *are* compiled in one 
> pass and *do* end up in 1 jar file. I tried this:
> 
>     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
>     Daughter daughter = null;
>     for (int i = 0; i < objs.length; i++) {
>         XmlObject myObj =  objs[i];
>                 
>         daughter =
(Daughter)Daughter.Factory.newInstance().set(myObj);
>         break;
>     }
>     if (daughter != null) {
>         int j = daughter.getAge();        
>     .....etc.....
> 
> or something very similar, and it worked!
> 
> As an xmlbeans newbie, I think the manipulation of 'Any's could be 
> made easier. It's a pity I couldn't have done something like:
> 
>     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
>     if (daughter != null) {
>     .....etc.....
> 
> After all, doesn't xmlbeans already have all of the information 
> required to extract the concrete from the Any?
> 
> Thanks again,
> 
> Des
> 
> -----Original Message-----
> From: David Jencks [mailto:david_jencks@yahoo.com]
> Sent: 20 June 2007 12:56
> To: user@xmlbeans.apache.org
> Subject: Re: Getting concrete object from Any
> 
> 1. IIUC your sample document should look like <myElem xmlns="mine"> 
> <myChlid> <daughter>foo</daughter> </myChild> </myElem>
> 
> 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> 
> If all your schemas are compiled at once into one jar I think this  
> will return the desired XmlObjects as the types you expect.   
> Otherwise if you get a plain XmlObject you may have to copy and call
> changeType(desiredSchemaType) on them.  When I do this I find that 
> trying to call changeType without making a new copy usually doesn't 
> work, but I'm also trying to glue together a lot of schema type 
> systems from several jars, so it may work better if all your schemas 
> are compiled at once.
> 
> hope this helps
> david jencks
> 
> On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> 
> > Sorry about Yet-Another-Any question, but this is my first 
> > expedition in Xmlbeans and I have seached the documentation and 
> > Javadocs and I'm still banging my head against a brick wall.
> >
> > Suppose I have a schema with an element, 'myElem', say. One of the 
> > child elements, 'myChild', is defined as:
> >
> >     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
> >     <xs:complexType name="MyChildType">
> >         <xs:sequence>
> > 	      <xs:any namespace="##any" processContents="lax"
> > maxOccurs="unbounded" />
> >         </xs:sequence>
> >     </xs:complexType>
> >
> > I can get at MyChild by:
> >
> >     MyChildType myChild = myElem.getMyChild();
> >
> > But, and you all know what's coming, how do I get the object that is
> > *actually* being carried in the place of the Any? I have tried using

> > XmlCursors to navigate to the object, but I really don't want to 
> > have to disassemble the XmlObject, what I really want is to get back

> > to the
> 
> > cosy world of gets and sets on the concrete objects.
> >
> > So, if I had a xml fragement that looked like:
> >
> >     <myElem>
> >         <daughter>britney spears</daughter>
> >     </myElem>
> >
> > What is the cleanest way of extracting the XmlObject and creating 
> > the associated 'daughter' xmlbean so that I can go back to :
> >
> > 	daughter.getAge();
> >
> > Assume that 'daughter' is the only element type that I'm prepared to

> > accept and that other elements will be rejected by the surrounding 
> > application as 'not supported'.
> >
> > Thanks for any help.
> >
> > Cheers, Des
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by Radu Preotiuc-Pietro <ra...@bea.com>.
My opinion is that it will just work even if you have multiple jars,
must be something else that complicates David's case (substitution
groups).

However, Desmond, it seems to me that what you suggest is exactly what
XmlBeans is doing today. Note that in your Schema, the <any> wildcard is
a child of the <myChild> element, so obviously you can't replace
<myChild> with <daughter>, but you need to have <daughter> as a child,
like so:

<myElem>
  <myChild>
    <daughter>britney spears</daughter>
  </myChild>
</myElem>

Or, you need to change your Schema.

Now if you do

MyChildType myChild = myElem.getMyChild();
XmlObject instance = myChild.selectChildren("", "daughter")[0];

you will see that "instance" already has the right type.

Radu

On Wed, 2007-06-20 at 15:31 +0200, Desmond Whewell (CV/ETL) wrote: 
> David,
> 
> Thank you for your help. Mercifully, my schemas *are* compiled in one
> pass and *do* end up in 1 jar file. I tried this:
> 
>     XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
>     Daughter daughter = null;
>     for (int i = 0; i < objs.length; i++) {
>         XmlObject myObj =  objs[i];
>                 
>         daughter = (Daughter)Daughter.Factory.newInstance().set(myObj);
>         break;
>     }
>     if (daughter != null) {
>         int j = daughter.getAge();        
>     .....etc.....
> 
> or something very similar, and it worked!
> 
> As an xmlbeans newbie, I think the manipulation of 'Any's could be made
> easier. It's a pity I couldn't have done something like:
> 
>     Daughter daughter = myElem.getMyChild().refine(Daughter.type);
>     if (daughter != null) {
>     .....etc.....
> 
> After all, doesn't xmlbeans already have all of the information required
> to extract the concrete from the Any?
> 
> Thanks again,
> 
> Des
> 
> -----Original Message-----
> From: David Jencks [mailto:david_jencks@yahoo.com] 
> Sent: 20 June 2007 12:56
> To: user@xmlbeans.apache.org
> Subject: Re: Getting concrete object from Any
> 
> 1. IIUC your sample document should look like <myElem xmlns="mine">
> <myChlid> <daughter>foo</daughter> </myChild> </myElem>
> 
> 2. Try XmlObject.selectChildren(QNameSet desiredQNames);
> 
> If all your schemas are compiled at once into one jar I think this  
> will return the desired XmlObjects as the types you expect.   
> Otherwise if you get a plain XmlObject you may have to copy and call
> changeType(desiredSchemaType) on them.  When I do this I find that
> trying to call changeType without making a new copy usually doesn't
> work, but I'm also trying to glue together a lot of schema type systems
> from several jars, so it may work better if all your schemas are
> compiled at once.
> 
> hope this helps
> david jencks
> 
> On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:
> 
> > Sorry about Yet-Another-Any question, but this is my first expedition 
> > in Xmlbeans and I have seached the documentation and Javadocs and I'm 
> > still banging my head against a brick wall.
> >
> > Suppose I have a schema with an element, 'myElem', say. One of the 
> > child elements, 'myChild', is defined as:
> >
> >     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
> >     <xs:complexType name="MyChildType">
> >         <xs:sequence>
> > 	      <xs:any namespace="##any" processContents="lax"
> > maxOccurs="unbounded" />
> >         </xs:sequence>
> >     </xs:complexType>
> >
> > I can get at MyChild by:
> >
> >     MyChildType myChild = myElem.getMyChild();
> >
> > But, and you all know what's coming, how do I get the object that is
> > *actually* being carried in the place of the Any? I have tried using 
> > XmlCursors to navigate to the object, but I really don't want to have 
> > to disassemble the XmlObject, what I really want is to get back to the
> 
> > cosy world of gets and sets on the concrete objects.
> >
> > So, if I had a xml fragement that looked like:
> >
> >     <myElem>
> >         <daughter>britney spears</daughter>
> >     </myElem>
> >
> > What is the cleanest way of extracting the XmlObject and creating the 
> > associated 'daughter' xmlbean so that I can go back to :
> >
> > 	daughter.getAge();
> >
> > Assume that 'daughter' is the only element type that I'm prepared to 
> > accept and that other elements will be rejected by the surrounding 
> > application as 'not supported'.
> >
> > Thanks for any help.
> >
> > Cheers, Des
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> > For additional commands, e-mail: user-help@xmlbeans.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,  copyrighted  and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


RE: Getting concrete object from Any

Posted by "Desmond Whewell (CV/ETL)" <de...@ericsson.com>.
David,

Thank you for your help. Mercifully, my schemas *are* compiled in one
pass and *do* end up in 1 jar file. I tried this:

    XmlObject[] objs = myChild.selectChildren(QNAME_DAUGHTER);
    Daughter daughter = null;
    for (int i = 0; i < objs.length; i++) {
        XmlObject myObj =  objs[i];
                
        daughter = (Daughter)Daughter.Factory.newInstance().set(myObj);
        break;
    }
    if (daughter != null) {
        int j = daughter.getAge();        
    .....etc.....

or something very similar, and it worked!

As an xmlbeans newbie, I think the manipulation of 'Any's could be made
easier. It's a pity I couldn't have done something like:

    Daughter daughter = myElem.getMyChild().refine(Daughter.type);
    if (daughter != null) {
    .....etc.....

After all, doesn't xmlbeans already have all of the information required
to extract the concrete from the Any?

Thanks again,

Des

-----Original Message-----
From: David Jencks [mailto:david_jencks@yahoo.com] 
Sent: 20 June 2007 12:56
To: user@xmlbeans.apache.org
Subject: Re: Getting concrete object from Any

1. IIUC your sample document should look like <myElem xmlns="mine">
<myChlid> <daughter>foo</daughter> </myChild> </myElem>

2. Try XmlObject.selectChildren(QNameSet desiredQNames);

If all your schemas are compiled at once into one jar I think this  
will return the desired XmlObjects as the types you expect.   
Otherwise if you get a plain XmlObject you may have to copy and call
changeType(desiredSchemaType) on them.  When I do this I find that
trying to call changeType without making a new copy usually doesn't
work, but I'm also trying to glue together a lot of schema type systems
from several jars, so it may work better if all your schemas are
compiled at once.

hope this helps
david jencks

On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:

> Sorry about Yet-Another-Any question, but this is my first expedition 
> in Xmlbeans and I have seached the documentation and Javadocs and I'm 
> still banging my head against a brick wall.
>
> Suppose I have a schema with an element, 'myElem', say. One of the 
> child elements, 'myChild', is defined as:
>
>     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
>     <xs:complexType name="MyChildType">
>         <xs:sequence>
> 	      <xs:any namespace="##any" processContents="lax"
> maxOccurs="unbounded" />
>         </xs:sequence>
>     </xs:complexType>
>
> I can get at MyChild by:
>
>     MyChildType myChild = myElem.getMyChild();
>
> But, and you all know what's coming, how do I get the object that is
> *actually* being carried in the place of the Any? I have tried using 
> XmlCursors to navigate to the object, but I really don't want to have 
> to disassemble the XmlObject, what I really want is to get back to the

> cosy world of gets and sets on the concrete objects.
>
> So, if I had a xml fragement that looked like:
>
>     <myElem>
>         <daughter>britney spears</daughter>
>     </myElem>
>
> What is the cleanest way of extracting the XmlObject and creating the 
> associated 'daughter' xmlbean so that I can go back to :
>
> 	daughter.getAge();
>
> Assume that 'daughter' is the only element type that I'm prepared to 
> accept and that other elements will be rejected by the surrounding 
> application as 'not supported'.
>
> Thanks for any help.
>
> Cheers, Des
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: Getting concrete object from Any

Posted by David Jencks <da...@yahoo.com>.
1. IIUC your sample document should look like
<myElem xmlns="mine">
<myChlid>
<daughter>foo</daughter>
</myChild>
</myElem>

2. Try XmlObject.selectChildren(QNameSet desiredQNames);

If all your schemas are compiled at once into one jar I think this  
will return the desired XmlObjects as the types you expect.   
Otherwise if you get a plain XmlObject you may have to copy and call  
changeType(desiredSchemaType) on them.  When I do this I find that  
trying to call changeType without making a new copy usually doesn't  
work, but I'm also trying to glue together a lot of schema type  
systems from several jars, so it may work better if all your schemas  
are compiled at once.

hope this helps
david jencks

On Jun 20, 2007, at 5:39 AM, Desmond Whewell (CV/ETL) wrote:

> Sorry about Yet-Another-Any question, but this is my first  
> expedition in
> Xmlbeans and I have seached the documentation and Javadocs and I'm  
> still
> banging my head against a brick wall.
>
> Suppose I have a schema with an element, 'myElem', say. One of the  
> child
> elements, 'myChild', is defined as:
>
>     <xs:element name="myChild" type="MyChildType" minOccurs="0" />
>     <xs:complexType name="MyChildType">
>         <xs:sequence>
> 	      <xs:any namespace="##any" processContents="lax"
> maxOccurs="unbounded" />
>         </xs:sequence>
>     </xs:complexType>
>
> I can get at MyChild by:
>
>     MyChildType myChild = myElem.getMyChild();
>
> But, and you all know what's coming, how do I get the object that is
> *actually* being carried in the place of the Any? I have tried using
> XmlCursors to navigate to the object, but I really don't want to  
> have to
> disassemble the XmlObject, what I really want is to get back to the  
> cosy
> world of gets and sets on the concrete objects.
>
> So, if I had a xml fragement that looked like:
>
>     <myElem>
>         <daughter>britney spears</daughter>
>     </myElem>
>
> What is the cleanest way of extracting the XmlObject and creating the
> associated 'daughter' xmlbean so that I can go back to :
>
> 	daughter.getAge();
>
> Assume that 'daughter' is the only element type that I'm prepared to
> accept and that other elements will be rejected by the surrounding
> application as 'not supported'.
>
> Thanks for any help.
>
> Cheers, Des
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org