File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generate Schema for XML

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to generate a schema for a given XML using any java API.
What about JAXP ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't generate an XSD from XML automatically - you wouldn't be able to define the ranges of values possible in an XSD, only reflect those present in the XML document. However, XSD is just XML so you certainly create one with Java.
 
Pete Tibbster
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are tools out there that can create you an xsd from an example xml file. I've used Trang in the past to do this. Download trang.jar
from here

To create the xsd file open a command propt and execute the following (replacing the xml/xsd values) --->

java -jar trang.jar example.xml generated.xsd

This creates you a basic xsd based on the example xml file. It won't be able to know what the restrictions are for individual elements from your example but this is something you can add later if you know them!

hope this helps.
 
N Larson
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we use a tool called Torque (http://db.apache.org/torque) You have your schema in XML and it will generate table Enums and the SQL to generate teh DB. There are also some tasks we have that compare schemas from two db to find the differences.

Check it out. Kinda confusing at first...but really nice!
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lott for all the replies.
I just downloaded Stylus Studio, I'll chk trang & Torque today.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic