You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Kahovec, Jakub" <j....@imperial.ac.uk> on 2005/01/12 17:56:37 UTC
how to get 'sub-level' components from a xml schema
Hi,
when I use
itemPSVI = (ItemPSVI)node;
XSModel model = ((ElementPSVI) itemPSVI).getSchemaInformation();
XSNamedMap map = model.getComponents(XSConstants.ELEMENT_DECLARATION);
I got only the top level components, but I would like to get sub-level componens which are related to a node.
For instance in following example how can I get sub-components (child nodes) of the Info element ?
<xs:element name="MqatDocument">
<xs:complexType>
<xs:sequence>
<xs:element ref="Info" minOccurs='1' maxOccurs='1'/>
<xs:element ref="Question" minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Info">
<xs:complexType>
<xs:sequence>
<xs:element name="Title" type='xs:string'/>
<xs:element name="Author" type='xs:string'/>
<xs:element name="Version" type='xs:string'/>
<xs:element name="Date" type='xs:string'/>
</xs:sequence>
</xs:complexType>
</xs:element>
Thanks for any ideas.
Jakub
Re: how to get 'sub-level' components from a xml schema
Posted by Stanimir Stamenkov <st...@myrealbox.com>.
/Kahovec, Jakub/:
> itemPSVI = (ItemPSVI)node;
>
> XSModel model = ((ElementPSVI) itemPSVI).getSchemaInformation();
>
> XSNamedMap map = model.getComponents(XSConstants.ELEMENT_DECLARATION);
>
> I got only the top level components, but I would like to get sub-level
> componens which are related to a node.
Get the 'XSElementDeclaration' directly from the 'ElementPSVI' and
analyze its type definition. If the type definition is a complex
type specifying mixed or element-only content you could analyze the
content model group particle (i.e. the children which are possibly
local declarations) further, and so on recursively for any child
element declarations, if you need.
--
Stanimir
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org