Hi Ed,
Do this:
XSParticle particle = complexTypeDef.getParticle();
if (particle != null)
{
processParticle(node, particle, level);
}
In the processParticle:
switch (particle.getTerm().getType()):
You wil get a modelgroup or element or wildcard.
Dick Deneer
Op 29-jun-2006, om 22:54 heeft Wax, Ed het volgende geschreven:
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]