This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Parsing XSD using Xerces

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to parse a generic XSD and create sample XMLs conforming to the XSD. I am using Xerces for Java.

Does Xerces provide support for parsing XSD or do i have to parse it as a regular XML ? If theres support in Xerces, how do i do it?
Also could someone point to way/technique by which i can create all possible XMLs conforming to an XSD.

Thanks.
 
Sheriff
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A schema is an XML document, so yes, Xerces does support parsing one as XML. I don't know what else you would want from Xerces anyway.

And if you think about it, almost any non-trivial schema describes an infinite number of possible XML documents, so there is no way to generate all of them.
 
Moha Shaf
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I understand that an XSD can be parsed as a normal XML but I do not wish to do that. I believe that there is an object representation of the XSD which the Xerces uses to validate an XML. Is there a way to get handle to that object and get information of the schema in a logical way using its methods or some other way.
I found a sample for the C++ version of xerces but not able to find the source of this sample --> http://xerces.apache.org/xerces-c/scmprint-3.html
Also I do not wish to generate all possible XMLs conforming to schema, I only want to generate the XMLs with boundary values for all the constraints in the schema.

Any help/ pointer would be appreciated.

Thanks.
 
Moha Shaf
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone tell if there is any equivalent API in Xerces Java to Traverse through the XSD and access different segments of the XSD in a logical way.
Any help would be appreciated.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!