Peter, There is no direct way to find the id of a schema type, but there is a work around: each compiled schema type points to its xsd file (see SchemaComponent.getSourceName()), once you have the file it's possible using xpath to find the type definition and the value of it's id attribute. If I'm not mistaken we're probably the very few people if not the first to ask about id attribute related to a schema type.
Cezar > -----Original Message----- > From: Peter Keller [mailto:[email protected]] > Sent: Tuesday, March 30, 2010 12:36 PM > To: [email protected] > Subject: Re: Getting at a schema component's id attribute > > > myTypeInstance.selectPath(XPathExpressionString) will do that. > > No it will not. Instances of schema components in XMLBeans are instances > of > classes that implement the interface org.apache.xmlbeans.SchemaType: the > giveaway here is that SchemaType has a super-interface called > SchemaComponent. Neither of these interfaces specify a selectPath method. > > selectPath is a method of XmlObject, and only provides access to instance > data, not metadata from the XSD that was used to generate the XMLBeans > API. > > The current XPath schema is available at http://www.w3.org/TR/xpath/ . It > has not changed since November 1999. It makes no reference to XML schemas > at > all: at that time the XML schema specification was only in its third > working > draft, and was not yet a standard. > > In principle, I could build an XMLBeans interface from the Schema for > Schemas at http://www.w3.org/2001/XMLSchema.xsd, and use that in > combination > with the original XSD files (assuming that they are available in all > cases). > If you re-read my original question, you will see that I was (in effect) > asking if the metadata that I am after are preserved in the API, so that I > could avoid doing that. > > > > > On 30 March 2010 16:01, Peter Keller <[email protected]> wrote: > > On Fri, 26 Mar 2010, Sri Harsha Yenuganti wrote: > > > > Try using the XMLBeans XQuery/XPath API features. > > > > > > It seems to me that you have not understood my question. I am not asking > how to retrieve data > > from an XML document. I am asking whether certain information from an > XML schema is available > > from the API that XMLBeans generates from that schema. > > > > Does anyone have an answer for my original question, or have I found an > area where XMLBeans > > support for XML schema is incomplete? > > > > Regards, > > Peter. > > > > > > > > On 26 March 2010 09:57, Peter Keller <[email protected]> > wrote: > > Dear all, > > > > I have been trying to figure out how to get the value of the > "id" attribute > > of a schema > > component, but have got nowhere. Can anyone help? > > > > Slightly more explicitly: if my XSD contains a type > definition like this: > > > > <complexType name="MyType" id="some_identifier_or_other"> > > ... > > </complexType> > > > > and I have an instance of this type "myTypeInstance", is > there some way that > > I can access the > > value of "id" by using "myTypeInstance.SchemaType()", or > otherwise? > > > > Regards, > > Peter. > > > > ------------------------------------------------------------- > -------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: user- > [email protected] > > > > > > > > > > -- > > Sri Harsha Yenuganti > > [email protected] > > > > " IF YOU ARE NOT BRAVE ENOUGH TO FACE A FAILURE YOU ARE UNFIT TO > SUCCEED.AIM > > HIGH BUT BE PREPARED FOR THE > > WORST. " > > > > > > > > > > > > -- > > Peter Keller Tel.: +44 (0)1223 > 353033 > > Global Phasing Ltd., Fax.: +44 (0)1223 > 366889 > > Sheraton House, > > Castle Park, > > Cambridge CB3 0AX > > United Kingdom > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > > > > > -- > > Sri Harsha Yenuganti > > [email protected] > > > > " IF YOU ARE NOT BRAVE ENOUGH TO FACE A FAILURE YOU ARE UNFIT TO > SUCCEED.AIM HIGH BUT BE PREPARED > > FOR THE WORST. " > > > > > > > > > > -- > Peter Keller Tel.: +44 (0)1223 353033 > Global Phasing Ltd., Fax.: +44 (0)1223 366889 > Sheraton House, > Castle Park, > Cambridge CB3 0AX > United Kingdom --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

