You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-user@xml.apache.org by Hagen Overdick <ha...@hpi.uni-potsdam.de> on 2004/01/27 20:43:03 UTC

any and anyAttribute

Howdi,


as XmlBeans does not produce accessors for <any> and <anyAttribute>, I 
am looking for a simple way to get everything, that is not reflected in 
the java interface.

So far, my best shot is using a cursor checking against 
getObject().schemaType().getProperties(). It's never clean nor pretty. 
Is there are better solution?

What's the design reason for leaving out <any> and <anyAttribute> in 
the first place?


Cheers

)-(agen


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


Re: any and anyAttribute

Posted by Ganga Sah <ga...@yahoo.com>.
I am also having the frustration of XMLBeans not
having an accessor method for "any" element like
getAny() as in Sun JAXB. I you mentioned, I also would
like to know why this is not available in XMLBeans
although it claims to map/bind 100% of XML Schema!

thanks,
ganga
--- Hagen Overdick <ha...@hpi.uni-potsdam.de>
wrote:
> Hi Ganga, Hi Kevin,
> 
> > In the thread below, eric explains how to use the
> XmlCursor.  Here's a
> > sample that uses strongly typed objects:
> 
> >>> as XmlBeans does not produce accessors for <any>
> and
> >>> <anyAttribute>, I
> >>> am looking for a simple way to get everything,
> that
> >>> is not reflected in
> >>> the java interface.
> >>>
> >>> So far, my best shot is using a cursor checking
> >>> against
> >>> getObject().schemaType().getProperties(). It's
> never
> >>> clean nor pretty.
> >>> Is there are better solution?
> 
> yes, I did see that thread, but is not the answer to
> my question. I am 
> writing a generic program, reacting to the XmlBeans
> it encounters 
> parsing a document. Basically, what I need is
> reflection on XmlBeans.
> 
> I need to quickly answer questions like:
> 
> - Is there an extension attribute (not covered by
> the java interface)
> - Is there an extension element (~)
> - Is there a spot, where I can add an extension
> 
> (Extension in this context basically being <any> and
> <anyAttribute>)
> 
> Your example just show, that if you know where you
> want the extension 
> to go, how to put it there.
> 
> Again, using
> cursor.getObject().schemaType().getProperties() to
> get the 
> schema of the element and then use the cursor to
> query what's really 
> included does not look pretty. Any options?
> 
> 
> Cheers
> 
> )-(agen
> 
> 
> -
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL:
> http://xml.apache.org/xmlbeans/
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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


Re: any and anyAttribute

Posted by Ganga Sah <ga...@yahoo.com>.
I am also having the frustration of XMLBeans not
having an accessor method for "any" element like
getAny() as in Sun JAXB. I you mentioned, I also would
like to know why this is not available in XMLBeans
although it claims to map/bind 100% of XML Schema!

thanks,
ganga
--- Hagen Overdick <ha...@hpi.uni-potsdam.de>
wrote:
> Hi Ganga, Hi Kevin,
> 
> > In the thread below, eric explains how to use the
> XmlCursor.  Here's a
> > sample that uses strongly typed objects:
> 
> >>> as XmlBeans does not produce accessors for <any>
> and
> >>> <anyAttribute>, I
> >>> am looking for a simple way to get everything,
> that
> >>> is not reflected in
> >>> the java interface.
> >>>
> >>> So far, my best shot is using a cursor checking
> >>> against
> >>> getObject().schemaType().getProperties(). It's
> never
> >>> clean nor pretty.
> >>> Is there are better solution?
> 
> yes, I did see that thread, but is not the answer to
> my question. I am 
> writing a generic program, reacting to the XmlBeans
> it encounters 
> parsing a document. Basically, what I need is
> reflection on XmlBeans.
> 
> I need to quickly answer questions like:
> 
> - Is there an extension attribute (not covered by
> the java interface)
> - Is there an extension element (~)
> - Is there a spot, where I can add an extension
> 
> (Extension in this context basically being <any> and
> <anyAttribute>)
> 
> Your example just show, that if you know where you
> want the extension 
> to go, how to put it there.
> 
> Again, using
> cursor.getObject().schemaType().getProperties() to
> get the 
> schema of the element and then use the cursor to
> query what's really 
> included does not look pretty. Any options?
> 
> 
> Cheers
> 
> )-(agen
> 
> 
> -
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL:
> http://xml.apache.org/xmlbeans/
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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


Re: any and anyAttribute

Posted by Hagen Overdick <ha...@hpi.uni-potsdam.de>.
Hi Ganga, Hi Kevin,

> In the thread below, eric explains how to use the XmlCursor.  Here's a
> sample that uses strongly typed objects:

>>> as XmlBeans does not produce accessors for <any> and
>>> <anyAttribute>, I
>>> am looking for a simple way to get everything, that
>>> is not reflected in
>>> the java interface.
>>>
>>> So far, my best shot is using a cursor checking
>>> against
>>> getObject().schemaType().getProperties(). It's never
>>> clean nor pretty.
>>> Is there are better solution?

yes, I did see that thread, but is not the answer to my question. I am 
writing a generic program, reacting to the XmlBeans it encounters 
parsing a document. Basically, what I need is reflection on XmlBeans.

I need to quickly answer questions like:

- Is there an extension attribute (not covered by the java interface)
- Is there an extension element (~)
- Is there a spot, where I can add an extension

(Extension in this context basically being <any> and <anyAttribute>)

Your example just show, that if you know where you want the extension 
to go, how to put it there.

Again, using cursor.getObject().schemaType().getProperties() to get the 
schema of the element and then use the cursor to query what's really 
included does not look pretty. Any options?


Cheers

)-(agen


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


Re: any and anyAttribute

Posted by Hagen Overdick <ha...@hpi.uni-potsdam.de>.
Hi Ganga, Hi Kevin,

> In the thread below, eric explains how to use the XmlCursor.  Here's a
> sample that uses strongly typed objects:

>>> as XmlBeans does not produce accessors for <any> and
>>> <anyAttribute>, I
>>> am looking for a simple way to get everything, that
>>> is not reflected in
>>> the java interface.
>>>
>>> So far, my best shot is using a cursor checking
>>> against
>>> getObject().schemaType().getProperties(). It's never
>>> clean nor pretty.
>>> Is there are better solution?

yes, I did see that thread, but is not the answer to my question. I am 
writing a generic program, reacting to the XmlBeans it encounters 
parsing a document. Basically, what I need is reflection on XmlBeans.

I need to quickly answer questions like:

- Is there an extension attribute (not covered by the java interface)
- Is there an extension element (~)
- Is there a spot, where I can add an extension

(Extension in this context basically being <any> and <anyAttribute>)

Your example just show, that if you know where you want the extension 
to go, how to put it there.

Again, using cursor.getObject().schemaType().getProperties() to get the 
schema of the element and then use the cursor to query what's really 
included does not look pretty. Any options?


Cheers

)-(agen


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


Re: any and anyAttribute

Posted by Kevin Krouse <kk...@bea.com>.
In the thread below, eric explains how to use the XmlCursor.  Here's a
sample that uses strongly typed objects:


====> anyTest.xsd <=====
<?xml version="1.0"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:tns="http://sample.openuri.info/anyTest"
  targetNamespace="http://sample.openuri.info/anyTest"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified">

  <xs:element name="product" type="tns:ProductType"/>

  <xs:complexType name="ProductType">
      <xs:sequence maxOccurs="unbounded">
        <xs:element name="something" type="xs:anyType"/>
      </xs:sequence>
  </xs:complexType>

</xs:schema>


====> AnySample.java <====
import org.apache.xmlbeans.*;
import info.openuri.sample.anyTest.ProductDocument;
import info.openuri.sample.anyTest.ProductType;

public class AnySample
{
    public static void main(String args[]) throws Exception
    {
        XmlOptions xoptions = new XmlOptions();
        xoptions.setSavePrettyPrint();

        ProductDocument pDoc =
            ProductDocument.Factory.newInstance();
        ProductType ptype = pDoc.addNewProduct();

        // setting an any from parsed xml
        String xml = "<xml-fragment>testing123</xml-fragment>";
        XmlObject xobj = ptype.addNewSomething();
        xobj.set(XmlObject.Factory.parse(xml));

        xobj = ptype.addNewSomething();
        xobj.set(XmlObject.Factory.parse("<zip>98033</zip>"));

        // setting an any from a strongly typed object
        XmlInt number = XmlInt.Factory.newInstance();
        number.setIntValue(3);

        xobj = ptype.addNewSomething();
        xobj.set(number);

        System.out.println("\nXML document \n");
        System.out.println(pDoc.xmlText(xoptions));
        System.out.println("Valid: "+pDoc.validate());

        // using the XmlCursor
        pDoc = ProductDocument.Factory.newInstance();
        ptype = pDoc.addNewProduct();

        xobj = ptype.addNewSomething();

        XmlCursor xcursor = xobj.newCursor();
        xcursor.toFirstContentToken();
        xcursor.insertChars("My Company, Inc");
        xcursor.dispose();

        System.out.println("\nXML document \n");
        System.out.println(pDoc.xmlText(xoptions));
        System.out.println("Valid: "+pDoc.validate());

    }
}






On Tue, 2004-01-27 at 12:13, Ganga Sah wrote:
> Hi,
> I had the same issue and had received reply on
> xmlbeans-dev mailing list thread(on 2004-01-05) below:
> http://nagoya.apache.org/eyebrowse/BrowseList?listName=xmlbeans-dev@xml.apache.org&by=thread&from=576182
> 
> thanks,
> ganga
> ---Hagen Overdick <ha...@hpi.uni-potsdam.de>
> wrote:
> > Howdi,
> > 
> > 
> > as XmlBeans does not produce accessors for <any> and
> > <anyAttribute>, I 
> > am looking for a simple way to get everything, that
> > is not reflected in 
> > the java interface.
> > 
> > So far, my best shot is using a cursor checking
> > against 
> > getObject().schemaType().getProperties(). It's never
> > clean nor pretty. 
> > Is there are better solution?
> > 
> > What's the design reason for leaving out <any> and
> > <anyAttribute> in 
> > the first place?
> > 
> > 
> > Cheers
> > 
> > )-(agen
> > 
> > 
> > -
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:  
> > xmlbeans-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail:
> > xmlbeans-user-help@xml.apache.org
> > Apache XMLBeans Project -- URL:
> > http://xml.apache.org/xmlbeans/
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
> 
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
> 

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


Re: any and anyAttribute

Posted by Kevin Krouse <kk...@bea.com>.
In the thread below, eric explains how to use the XmlCursor.  Here's a
sample that uses strongly typed objects:


====> anyTest.xsd <=====
<?xml version="1.0"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:tns="http://sample.openuri.info/anyTest"
  targetNamespace="http://sample.openuri.info/anyTest"
  elementFormDefault="qualified"
  attributeFormDefault="unqualified">

  <xs:element name="product" type="tns:ProductType"/>

  <xs:complexType name="ProductType">
      <xs:sequence maxOccurs="unbounded">
        <xs:element name="something" type="xs:anyType"/>
      </xs:sequence>
  </xs:complexType>

</xs:schema>


====> AnySample.java <====
import org.apache.xmlbeans.*;
import info.openuri.sample.anyTest.ProductDocument;
import info.openuri.sample.anyTest.ProductType;

public class AnySample
{
    public static void main(String args[]) throws Exception
    {
        XmlOptions xoptions = new XmlOptions();
        xoptions.setSavePrettyPrint();

        ProductDocument pDoc =
            ProductDocument.Factory.newInstance();
        ProductType ptype = pDoc.addNewProduct();

        // setting an any from parsed xml
        String xml = "<xml-fragment>testing123</xml-fragment>";
        XmlObject xobj = ptype.addNewSomething();
        xobj.set(XmlObject.Factory.parse(xml));

        xobj = ptype.addNewSomething();
        xobj.set(XmlObject.Factory.parse("<zip>98033</zip>"));

        // setting an any from a strongly typed object
        XmlInt number = XmlInt.Factory.newInstance();
        number.setIntValue(3);

        xobj = ptype.addNewSomething();
        xobj.set(number);

        System.out.println("\nXML document \n");
        System.out.println(pDoc.xmlText(xoptions));
        System.out.println("Valid: "+pDoc.validate());

        // using the XmlCursor
        pDoc = ProductDocument.Factory.newInstance();
        ptype = pDoc.addNewProduct();

        xobj = ptype.addNewSomething();

        XmlCursor xcursor = xobj.newCursor();
        xcursor.toFirstContentToken();
        xcursor.insertChars("My Company, Inc");
        xcursor.dispose();

        System.out.println("\nXML document \n");
        System.out.println(pDoc.xmlText(xoptions));
        System.out.println("Valid: "+pDoc.validate());

    }
}






On Tue, 2004-01-27 at 12:13, Ganga Sah wrote:
> Hi,
> I had the same issue and had received reply on
> xmlbeans-dev mailing list thread(on 2004-01-05) below:
> http://nagoya.apache.org/eyebrowse/BrowseList?listName=xmlbeans-dev@xml.apache.org&by=thread&from=576182
> 
> thanks,
> ganga
> ---Hagen Overdick <ha...@hpi.uni-potsdam.de>
> wrote:
> > Howdi,
> > 
> > 
> > as XmlBeans does not produce accessors for <any> and
> > <anyAttribute>, I 
> > am looking for a simple way to get everything, that
> > is not reflected in 
> > the java interface.
> > 
> > So far, my best shot is using a cursor checking
> > against 
> > getObject().schemaType().getProperties(). It's never
> > clean nor pretty. 
> > Is there are better solution?
> > 
> > What's the design reason for leaving out <any> and
> > <anyAttribute> in 
> > the first place?
> > 
> > 
> > Cheers
> > 
> > )-(agen
> > 
> > 
> > -
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:  
> > xmlbeans-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail:
> > xmlbeans-user-help@xml.apache.org
> > Apache XMLBeans Project -- URL:
> > http://xml.apache.org/xmlbeans/
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free web site building tool. Try it!
> http://webhosting.yahoo.com/ps/sb/
> 
> - ---------------------------------------------------------------------
> To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
> 

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


Re: any and anyAttribute

Posted by Ganga Sah <ga...@yahoo.com>.
Hi,
I had the same issue and had received reply on
xmlbeans-dev mailing list thread(on 2004-01-05) below:
http://nagoya.apache.org/eyebrowse/BrowseList?listName=xmlbeans-dev@xml.apache.org&by=thread&from=576182

thanks,
ganga
---Hagen Overdick <ha...@hpi.uni-potsdam.de>
wrote:
> Howdi,
> 
> 
> as XmlBeans does not produce accessors for <any> and
> <anyAttribute>, I 
> am looking for a simple way to get everything, that
> is not reflected in 
> the java interface.
> 
> So far, my best shot is using a cursor checking
> against 
> getObject().schemaType().getProperties(). It's never
> clean nor pretty. 
> Is there are better solution?
> 
> What's the design reason for leaving out <any> and
> <anyAttribute> in 
> the first place?
> 
> 
> Cheers
> 
> )-(agen
> 
> 
> -
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL:
> http://xml.apache.org/xmlbeans/
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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


Re: any and anyAttribute

Posted by Ganga Sah <ga...@yahoo.com>.
Hi,
I had the same issue and had received reply on
xmlbeans-dev mailing list thread(on 2004-01-05) below:
http://nagoya.apache.org/eyebrowse/BrowseList?listName=xmlbeans-dev@xml.apache.org&by=thread&from=576182

thanks,
ganga
---Hagen Overdick <ha...@hpi.uni-potsdam.de>
wrote:
> Howdi,
> 
> 
> as XmlBeans does not produce accessors for <any> and
> <anyAttribute>, I 
> am looking for a simple way to get everything, that
> is not reflected in 
> the java interface.
> 
> So far, my best shot is using a cursor checking
> against 
> getObject().schemaType().getProperties(). It's never
> clean nor pretty. 
> Is there are better solution?
> 
> What's the design reason for leaving out <any> and
> <anyAttribute> in 
> the first place?
> 
> 
> Cheers
> 
> )-(agen
> 
> 
> -
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:  
> xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail:
> xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL:
> http://xml.apache.org/xmlbeans/
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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