[
Lists Home |
Date Index |
Thread Index
]
> I need to parse an XML Schema and get the following
> information out of it:
> list of elements starting from the root, and then the children.
> list of attributes for each element
>
> Is there a simple API for doing what I need?
There's no standard API for doing this, you need to look in the
specifications of the product you are using.
If you're using Saxon as the schema validator, you can load a schema using
the method
Configuration.addSchemaSource()
You can then locate an element declaration using
Configuration.getElementDeclaration()
You can get the type of an element declaration using
ElementDecl.getType()
You can get the particles (i.e. child elements) of a complex type using
UserComplexType.getExtendedParticle(), casting to a Compositor if
appropriate, then using iterateParticles()
You can get the attributes permitted by a complex type using
UserComplexType.getExtendedAttributeGroup()
Please note that a schema does not define a "root" element - any of the
global element declarations can define a possible root element.
Michael Kay
http://www.saxonica.com/
|