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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...