A repository for all blinkbox books XML schemas, along with example messages.
Maintain a folder structure which relates to the namespace.
http://schemas.blinkboxbooks.com/events/clients/v1should be translated to the following directory:
Each directory should have one schema file called
So from the previous example we would have:
For each schema, you should create at least one example XML file in the same directory.
Continuing from our previous example:
There is a small utility written in Ruby which validates all schemas against their respective examples.
This utility requires Ruby 2.0.0 or later and bundler.
Ensure you have bundler installed, as it is used to load dependencies:
$ gem install bundler
You can install all the dependencies using the
$ bundle install
Make sure that the script is runnable:
$ chmod +x validate
Running the validator
To validate all your XML schemas execute the the following command:
You can see from the output:
- Each directory it visits
- Each XML it runs against each XSD
- Valid or invalid indicators along with any validation errors
- Whether a file was skipped
- File statistics
Why a file was skipped?
The validator expects that on each directory there is only one
schema.xsd and at least one example XML file to validate against the schema.
If there is a
schema.xsd but there are no XML files, then it skips the validation for that file.
It is advised that you have at least one XML file for each
schema.xsd, unless there are exceptional circumstances where there cannot be an XML to validate against that schema (e.g., the schema defines only attributes).