Jump to content

Create XSD from XML structure


Guest ermal
 Share

Recommended Posts

Hi, i have an XML document where there is defined the structure of some tables, now i have to read these xml file and create a different xsd for eachof the tables described in the xml file. Any idea of how to do this? I was thinking of an XSLT transformation but i'm not sure.The structure of the xml file is something like this: <HEADER> <COLUMNS> <COLUMN ID='col1' LENGTH='10' TYPE='string' REQURED='true'/> <COLUMN ID='col2' LENGTH='5' TYPE='Date' REQUIRED='false'/> </COLUMNS> </HEADER> <BODY> <COLUMNS> <COLUMN ID='col1' LENGTH='10' TYPE='string' REQURED='true'/> <COLUMN ID='col2' LENGTH='5' TYPE='Date' REQUIRED='false'/> </COLUMNS> </BODY>

Link to comment
Share on other sites

An XSD describes the kind of nodes an XML document can contain. If the tables you're talking about are DB tables, then you don't need to generate an XSD, you need to generate an appropriate SQL creation query instead, which you cast thereafter, and that can happen with XSLT, or with plain XML parsing APIs like DOM.Play around with XSLT or something, and see where it leads you. Creating a stylesheet that works for all combinations may be tricky, but certainly not impossible.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...