aspose file tools*
The moose likes XML and Related Technologies and the fly likes Help !! Parsing Schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Help !! Parsing Schema " Watch "Help !! Parsing Schema " New topic
Author

Help !! Parsing Schema

Priyank kumar Tiwari
Greenhorn

Joined: Aug 11, 2005
Posts: 4
Hi,

My goal is to take an XML Schema, transform the schema into a DOM structure that I can Traverse .I am using Jdom ,and I am able to parse the schema ,but I am facing problem for the cases when my schema is including (or importing)some other xsd's .In those cases I am unable to get a handle to those complex elements present in external xsd.Please suggest some parser to do that .
Does anyone know of an API that will help me do this in Java??

Thanks in advance,

--------------------
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
I recommend castor. Castor allows you to specify a binding file to handle this type of requirement.
Priyank kumar Tiwari
Greenhorn

Joined: Aug 11, 2005
Posts: 4
Hi Andy,

Thanks for the suggestion .I am looking into it .I have worked fairly a lot on SAX/DOM but didnt ever got a chance to work in castor,can you please recommend me some good tutorial or link where I can get all relevent details on Castor.I was going through some discussion forums ,and people are having some issues when the including schemas have enums or complex contents.So it would be very helpful if you (or anybody :-)Plzzz )can suggest a place where I can get good material on it ,

Thanks a lot for your reply..
Gabriel Buheler
Ranch Hand

Joined: Apr 21, 2004
Posts: 39
Also you can look at this API:

XSOM

There it is few documentation, but I think that support included schemas.


Now,
Could you please help me with a schema parser?
Basically I need:

I want to parse a xsd file.

For example, �test.xsd� file:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="note" type="NoteType"/>
<xsd:complexType name="NoteType">
<xsd:sequence>
<xsd:element name="to" type="xsd:string"/>
<xsd:element name="from" type="xsd:string"/>
<xsd:element name="heading" type="xsd:string"/>
<xsd:element name="body" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

And I want to print important elements:

Like:

Note
To
From
Heading
Body

How can I do that? Could your provide me with an example?

Thanks in advance,

Gabriel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help !! Parsing Schema