How to parse XSD's ?

Hi,

starting from an XML Schema like this:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:complexType name="C1">

<xsd:sequence>

<xsd:element name="e1" type="E1"/>

<xsd:element name="e2" type="E2"/>

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="E1">

<xsd:sequence>

<xsd:element name="s1" type="xsd:string"/>

</xsd:sequence>

</xsd:complexType>

<xsd:complexType name="E2">

<xsd:sequence>

<xsd:element name="s2" type="xsd:long"/>

<xsd:element name="s3" type="xsd:long"/>

</xsd:sequence>

</xsd:complexType>

<xsd:element name="c1" type="C1"/>

</xsd:schema>

I need to get the defined element types:

C1= { E1 e1; E2 e2; }

E1= { String s1; }

E2= { long s2; long s3; }

I found XML Schema API, but there's not an example for using it.

Is there anyone that can help me?

Thanks in advance. - gNoLo

[1512 byte] By [gNoLoa] at [2007-11-26 18:17:47]
# 1
You should use data binding technologies, checks the JAXB 2 specification on jcp.org.You can also parse XML documents (this xsd is also xml document from XML format point of view) with normal XML parsers like DOM,SAX, StAX, TrAX
RezaRavasizadeha at 2007-7-9 5:51:24 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Thanks for your reply.

I know JAXB and I use it in my application to generate java classes from a schema.

Now I need to retrieve at runtime information regarding those generated classes, so I have to parse the schema...

I'm searching for an existent schema parser before coding it from scratch using DOM or SAX, and I found the XML Schema API, but seems very hard to use.

gNoLoa at 2007-7-9 5:51:24 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Good morning,I've exactly your same problem and I find using xml schema api very hard.Did you find something useful?Thanks in advance
ventodimarea at 2007-7-9 5:51:24 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
An XML Schema is an XML file. Any parser that parses XML files can be used to parse the XML Schema. Have you tried to parse the XML Schema with a SAX-based XML Parser? How about a DOM-based XML Parser?
GhostRadioTwoa at 2007-7-9 5:51:24 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...