Hi Birch
The ‘bar’ element isn’t
so much anonymous as local. There is a way of getting to local elements’
annotations (and hence appInfo elements) but it is not altogether obvious. A
JIRA has been raised to look at making it simpler to get to such annotations (http://issues.apache.org/jira/browse/XMLBEANS-195).
But until we find time to get to this here’s how you can get to what you
want:
- Get
the SchemaType from EquipmentModeInformationObjectType.type;
- Use
getContentModel() on the SchemaType to get a SchemaParticle representing
the sequence
- Use
getParticleChildren() on this to get a list of the children of this
sequence (this will include all the children that you “inherit”
through the extension
- Loop
through til you get to the one you want (compare the QName you get from
getName() to the one you want) (or alternatively if you know which child
it will be you can use getParticleChildren(int))
- Cast
that one to a SchemaLocalElement
- Call
getAnnotation() on the SchemaLocalElement returning a SchemaAnnotation
- Call
getApplicationInfo() on the SchemaAnnotation
Sorry it’s so complicated.
Cheers,
Lawrence
From: J B
[mailto:[EMAIL PROTECTED]
Sent: Friday, September 16, 2005
12:54 PM
To: user@xmlbeans.apache.org
Subject: Anonymous Elements
I am struggling with
finding elements that are defined in an anonymous manner.
For instance, take the following XML fragment:
<xs:complexType
name="EquipmentModeInformationObjectType">
<xs:complexContent>
<xs:extension
base="base:InformationObjectType">
<xs:sequence>
<xs:element ref="domain:foo"/>
<xs:element name="bar"
type="xs:string" minOccurs="0">
<xs:annotation>
<xs:appinfo>
<ui:fieldAccessMetadata xmlns:ui="urn:espace-consumption:ui">
<ui:commonName>Mode Name</ui:commonName>
</ui:fieldAccessMetadata>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Using the type system, I can find the 'EquipmentModeInformationObjectType'.
I can then loop through it's properties and get the element types. Since
'domain:foo' is a globaltype, to access the eleemnt, I can do a findElements on
the schemaTypeSystem and find it. But the 'bar' element is an anonymous
element. I can get the type, but I need access to the element in order to
access the appInfo underneath.
Can someone point me in the right direction to get thisinformation?
Thanks!
Birch
|