Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parse XML Schema Document

 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, is there a way to parse an XSD so I can iterate over the various elements in it? It may be a complex XSD that imports elements from other XSDs as well, and I'd like to be able to iterate over the child elements of the imported elements. Thanks!
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XSD is nothing but XML.You can do parsing the very same way we do for XML using XML parsers.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Agreed, but what happens when my xsd document imports elements from another document? I want to be able to access the child elements of the imported element, not just the name of the imported element.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?

Bill
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It treats it just like a regular XML document as I expected. So, if I had the following snippet:



where c:address is the address type imported from another schema. I'd like to be able to get at the fields within address (say, line1, line2, city, state, zip). This seems like it could be some pretty tedious code to write, so I'm wondering if any libraries already do it, but I couldn't find any.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic