Parse XML Schema in Java

A

Anna

Hi all.
I need to parse an XML Schema and get the following information out of
it:
list of elements allowed in schema
list of attributes for each element - which are required and which
optional
given an element name get elements that it can contain
etc.

Parsing with JDOM XPath seems to be complicated, because there are
many ways to say something in schema, although it would be my
preferred way.

I also looked at JAXB and Xerces, but their APIs seem to be more
complicated than I need.

Is there a simple API for doing what I need?

Thank you very much for help.

Anna
 
M

Martin Honnen

Anna wrote:

I need to parse an XML Schema and get the following information out of
it:
list of elements allowed in schema
list of attributes for each element - which are required and which
optional
given an element name get elements that it can contain
etc.

Parsing with JDOM XPath seems to be complicated, because there are
many ways to say something in schema, although it would be my
preferred way.

I also looked at JAXB and Xerces, but their APIs seem to be more
complicated than I need.

Is there a simple API for doing what I need?

The W3C DOM Level 3 has validation module with an API that should allow
you to get the information that you describe above, it is documented at
http://www.w3.org/TR/2004/REC-DOM-Level-3-Val-20040127/
The Oracle XML developers kit as documented at
http://otn.oracle.com/tech/xml/xdk/xdkbeta.html
claims to implement
DOM Level 3.0 Validation(working draft dated 8th October 2002)
but I haven't tested that. I don't know whether there are other
implementations of that DOM specification available, the implementation
report at
http://www.w3.org/2003/07/DOM-Level-3-Val-implementations.html
speaks of three implementations.

Other than that I think Xerces is the way to go but you have had a look
at that already as you said.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top