Parse XML Schema in Java

Anna (archive)

Usenet Archive
Joined
Nov 2, 2001
Messages
93
Reaction score
0
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
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
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
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top