Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Traversing a schema
Traversing a schema [message #590365] Thu, 19 August 2004 00:10
Gary J is currently offline Gary JFriend
Messages: 61
Registered: July 2009
Member
I'm sure this is a total newbie question but I'm still oretty new to the
Schema Infoset Model and am having a little trouble wrapping my brain around
it so I'm taking it one step at a time and hopefully don't annoy people too
much with these simple questions. I'm afraid this is a little long so
please bear with me. I promise to write a "XML Schema Infoset Model for
Idiots" article when this is all done to avoid this in the future :)

I mentioned in another post that I process all the element declarations in a
schema like this:

EList elements = schema.getSchema().getElementDeclarations()
for (Iterator iter = elements.iterator(); iter.hasNext(); )
{
XSDElementDeclaration element = (XSDElementDeclaration)iter.next();
// do something with the element
}

So if I come to something like this:

<xsd:element name="Start">
<xsd:complexType>
<xsd:choice>
<xsd:element name="item1" type="xsd:string</xsd:element>
<xsd:element name="item2" type="xsd:string</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>

The object "element" will contain the XSDElementDeclaration for the schema
element "Start". I can even see the name of this element (Start) using
element.getName();

Here's where things get a little hairy for guys like me who are just
starting out with the schema model. Could someone please let me know when I
go off the rails?

At this point I've got my "element" object which contains the schema element
named "Start". Now I know that a schema element can be either a simple or
complex type. If it is a simple type I don't need to go much further for
now. If it is a complex type I need to do some further processing to get
the contents.

I check if the element is a complexType:

XSDParticle particle = type.getComplexType();

If I get back null that means the element is a simple type. In this example
I get back a particle which tells me I have a complex type.

So I obtain the contents of the complex type:

XSDParticleContent content = particle.getContent();

To me this means I'm sitting right about here in the schema:

--> <xsd:choice>
<xsd:element name="item1" type="xsd:string</xsd:element>
<xsd:element name="item2" type="xsd:string</xsd:element>
</xsd:choice>

That's where I get lost. I know that I should be able to see the
<xsd:choice> element as some item in "content" but I do not know where to
find it.

Could anyone give me a few pointers?

Thanks

Gary
Previous Topic:How to find "root" element in a schema. Check if an element is referenced
Next Topic:JDOM & Eclipse
Goto Forum:
  


Current Time: Thu Apr 25 21:18:11 GMT 2024

Powered by FUDForum. Page generated in 0.02318 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top