Take a look at:
http://www.w3.org/Submission/2004/SUBM-xmlschema-api-20040122/

An XSParticle has an XSTerm (accessed via getTerm) which is either an
XSElementDeclaration or an XSWildcard or an XSModelGroup (sequence,
choice or all).

It helps to read the above spec in conjunction with the XML Schema
spec because the class names reflect the terminology in the schema
spec, for the most part.

Jeff

On 6/29/06, Wax, Ed <[EMAIL PROTECTED]> wrote:
I'm attempting to read a schema so that I can ascertain the structure as
well as data types of the elements.  For complexTypes I can get close
but can't quite get down to the elements.  I can see them in a string
representation but cannot find an API to step through them.

Here's a complexType definition:
...
<xsd:complexType name = "addressA">
    <xsd:sequence>
        <xsd:element ref="Line1" />
        <xsd:element ref="Line2" minOccurs="0" />
        <xsd:element ref="City"/>
        <xsd:element ref="State" />
        <xsd:element ref="PostalCode" />
    </xsd:sequence>
</xsd:complexType>
...

Here's the code snippet:
...
// parse document
System.out.println("Parsing " + argv[0] + "...");
XSModel model = schemaLoader.loadURI(argv[0]);
if (model != null) {
    XSNamedMap ccomponents =
model.getComponents(XSTypeDefinition.COMPLEX_TYPE);
    int complexcount = ccomponents.getLength();
    XSComplexTypeDefinition complexType = null;
    XSParticle particle = null;
    for (int i = 0; i < complexcount; i++) {
        complexType = (XSComplexTypeDefinition)ccomponents.item(i);
        System.out.println("name: " + complexType.getName() +
complexType.getParticle());
    }
}
...

And, here's the output:
name:
addressA(("":Line1),("":Line2){0-1},("":City),("":State),("":PostalCode)
)

Is there an API that will allow me to parse/navigate the
complexType.Particle() object?  If so, do I need to make yet another
call to get the actual element definition (and its data type)?

Thanks,
Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to