Validating XSD against XML In  Ruby On Rails.(Part 1)

XMLSchema Validator Helper For Ruby on Rails

Introduction to XSD/XMLSchema

Before I get into the actual implementation of XMLSchema Validation, I would like to give a brief introduction to what is XSD and why do we actually need to validate the xml against its XSD. 

XML Schema can be used to express a schema: a set of rules to which an XML document must conform in order to be considered ‘valid’ according to that schema. However, unlike most other schema languages, XML Schema was also designed with the intent of validation resulting in a collection of information adhering to specific datatypes, which can be useful in the development of XML document processing software, but which has also provoked criticism.For more info…you can check out the w3c based standards for the Xml Schema at the following link:

http://www.w3.org/XML/Schema

The Xml support for our rails framework is not up to the expectations, with  REXML library providing some kind of support doing some basic xml operations which does not support xml validate which generally tend to go slow when the app is exposed to the production environment.

So, after 2 hours of  hardcore googling, I finally came up with the xmlstratlet command line utility.

XMLStarlet is a command line XML toolkit which can be used to transform,

query, validate, and edit XML documents and files using  simple set of shell

commands in similar way it is done for plain text files  using grep/sed/awk/

tr/diff/patch.

For more info, you can reach the xmlstartlet utility at the following website:

http://xmlstar.sourceforge.net/

You can download the latest version of  the xmlstartlet library at the following location:

http://xmlstar.sourceforge.net/download.php

 

So, with this base knowledge in our brains, we can now move to the core validation of xml using xsd in oour next part

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • blogmarks
  • Book.mark.hu
  • co.mments
  • Technorati
  • YahooMyWeb
  • IndianPad
  • DZone