Sunday, July 10, 2011

Generate .xsd Schema file from .xml file

When you are using JAXB(Java Architecture for XML Binding), you must require xml document to be converted into .xsd file. There is one Open Source called "trang" which does same thing. It takes .xml file as input and give .xsd as output. You can also use XMLSpy but It's not free. you will be provided 30 days trial.

1. Download "Trang"and Copy .jar files to local
2. Generate .xsd file using command as below using command prompt

java -jar trang.jar app-defaults.xml app-defaults.xsd

Note : app-defaults.xml is existing input .xml file and app-defaults.xsd is file which will generate after running this command.

<?xml version="1.0" encoding="UTF-8"?>

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="" elementFormDefault="qualified">
<xs:element name="AppDefaults">
<xs:element ref="RegionMasterURL"/>
<xs:element ref="ShowTime"/>
<xs:element ref="FadeTime"/>
<xs:element ref="DefaultRegion"/>
<xs:element name="RegionMasterURL" type="xs:anyURI"/>
<xs:element name="ShowTime" type="xs:integer"/>
<xs:element name="FadeTime" type="xs:integer"/>
<xs:element name="DefaultRegion" type="xs:integer"/>

No comments:

Post a Comment