We can get XML from XSD by using tools like
1. Eclipse IDE ( java Development Tool)
2. NetBeans IDE
3. Stylus studio.
Let me give the example to create an XML from XSD using tool - stylus studio.( if you don't have download the evaluation version .. I did the same (..)
Lets take an XSD ( from w3 school website- http://www.w3schools.com/schema/schema_example.asp) .. here it is
<----
save this as schema.xsd in notepad .
now open this xsd in stylus studio , this will open the XSD in Diagram view.
select any node and right click - View sample XML.( see above screen shot). you will get a XML document like this.
.
<?xml version="1.0"?>
<shiporder orderid="string" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///c:/Documents%20and%20Settings/sanjeevk/Desktop/schema.xsd">
<orderperson>string</orderperson>
<shipto>
<name>string</name>
<address>string</address>
<city>string</city>
<country>string</country>
</shipto>
<!--Element item, maxOccurs=unbounded-->
<item>
<title>string</title>
<!--Element note is optional-->
<note>string</note>
<quantity>635000</quantity>
<price>1.23</price>
</item>
<item>
<title>string</title>
<!--Element note is optional-->
<note>string</note>
<quantity>635000</quantity>
<price>1.23</price>
</item>
<item>
<title>string</title>
<!--Element note is optional-->
<note>string</note>
<quantity>635000</quantity>
<price>1.23</price>
</item>
</shiporder>
This a default XML that is generated. Tool has a setting to generate the other mandatory / optional elements or attributes as well ..
Tools- Options - XML schema Editor->XML schema to XML
see the screen shot below..Any question , please leave your comments.
No comments:
Post a Comment