Jump to content

Create XSD from XML structure


Guest ermal

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...