July 30, 2012

Techbits #19: How can an XSD be constructed from an XML?

You have an XML file but do not have its schema definition (XSD). Now, you would like to get your hands on one of its possible XSDs. What do you do?

Helpful information on how to generate XSD from XML can be found at http://www.dotkam.com/2008/05/28/generate-xsd-from-xml/. This would be useful in getting you started when you encounter any necessity to build and provide schema definitions for XML files.

Specifically, "trang" is the open source utility, located at http://www.thaiopensource.com/relaxng/trang.html, that does the job fairly good enough. Note that there're other utilities as well but many of them are commercial.

Note that there are tools available online that require you to upload an XML file, which will then be processed after which its XSD can be downloaded. However, this approach poses security risks and cannot be used in the case of files carrying sensitive content. This becomes all the more critical in the case of any files related to your work as it could become a corporate violation. As such, this word of caution of not using online tools for official work has to be kept in mind at all times.

No comments: