Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help !! Parsing Schema

 
Priyank kumar Tiwari
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recommend castor. Castor allows you to specify a binding file to handle this type of requirement.
 
Priyank kumar Tiwari
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic