There are several tools out there to create (or to infer) an XSD schema from XML document. I liked trang command line tool the most. Found it first when reading about Spring web services in Spring in Action book (very good book btw). Here are four simple steps how to create XSD from XML* using trang: Step 1. Get trang Download trang.zip from here (at the moment of writing “trang-20030619.zip”) Step 2. Extract it Use “unzip trang-version.zip”, or just winzip/winrar/7z etc.. if on windows Step 3. Make an alias This step is optional, but makes it extremely easy to run the tool with a single command. Make an alias to the “trang.jar” by (in my case Ubuntu/Linux) editing “~/.bashrc” and adding the following: # execute trang.jar (create XSD from XMLs) above “~/soft/utils/trang” is the directory where “trang” was unzipped to. Step 4. Create XSD from XML Let’s look at the XML file we need an XSD for: $ ls -l <?xml version="1.0" encoding="UTF-8"?> now run the tool against it: $ xml2xsd holiday-request.xml hr.xsd <?xml version=”1.0″ encoding=”UTF-8″?> done! $ * – NOTE: “trang” can create an XSD from multiple XML documents, not just one. List of other tools to use as an alternative to trang:
XSD away, Good Luck! Courtsey: dotkam |
Thursday, March 4, 2010
Generate XSD from XML
Posted by Mr.Late at 3:26 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment