A tutorial is a wonderful thing. Learning how to write Schematron rules with a tutorial is also a wonderful thing. Unfortunately validating XML instance files against a Schematron schema is not always easy. But if it is cumbersome to work with Schematron schemas, then going through the tutorial is also no fun. XML ValidatorBuddy makes it easy to validate XML instance files against a Schematron rule set directly within XMLSpy. This enables you to focus on Schematron itself and not on how to use it.

I take the files from chapter 7 of the Schematron tutorial available at http://www.dpawson.co.uk/schematron/keys.html . Of course the method described here to create and validate the sample files can also applied on any other chapter of the tutorial.

The basic steps are:

  1. Select and copy the content of the Schematron schema and XML sample instance files directly from the web pages of the tutorial (with Ctrl+C).
  2. Create a new .sch document for the Schematron schema and a new .xml document for the sample XML in XMLSpy. Paste the file content with Ctrl+V.
  3. Save the files anywhere you like.
  4. Add a folder to the Project open in XMLSpy and put both into the new folder. ValidatorBuddy recognizes that there is a .sch file in the same project folder as the XML instance and takes this schema for Schematron validation.
  5. Make the .xml file the active document in XMLSpy.
  6. Press “Validate” on the Schematron tab of the XML ValidatorBuddy plugin window.
  7. Check the results :-)
After doing this the Schematron tab shows the following result:

Schematron tutorial chapter 7 result

Schematron tutorial chapter 7 result

Share/Save/Bookmark

, ,

Here is a summary of the changes in XML ValidatorBuddy 2.6:

Copy validation report in XMLSpy as XML

In the past it was not possible to access the validation report in the XMLSpy plugin for further processing beside scrolling through the error list and selecting the error location. Now the Schematron and Xerces tab are providing a button to copy the validation results as a new XML document in XMLSpy. The XML has the same structure as the log file generated by a batch validation.

Validate instance files with selected Schema

Validation from the Windows File Explorer supports a new command to validate one or multiple XML instance files against a selected schema file. This command overwrites any present xsi:SchemaLocation or xsi:NoNamespaceSchemaLocation. If no schema location attribute is in the XML root element the schema is loaded as NoNamespaceSchemaLocation. This functionality uses the Xerces SAX validator and is therefore also handy on validating huge files without any schema already assigned.

Creation of batch log in UTF-8

The batch log file is now written in UTF-8 encoding. The UTF-16 format without a BOM which was used in the past caused some problems on reading. Several people requested to change this to UTF-8. Of course this is the better choice anyways.

Share/Save/Bookmark

, ,

Some weeks ago Altova released the new versions of their products. XMLSpy 2010 comes now with a brand new scripting tool to provide custom forms, macros and support for any kind of automation possible with the built-in API of XMLSpy:

New scripting tool in XMLSpy 2010

New scripting tool in XMLSpy 2010

XMLSpy already comes with some sample scripts to show how to implement macros and forms. If you try it yourself and you start to write some code in the Script tool you will notice that there are also entry helpers available for the XMLSpy API. Very useful.

There are two macros available which I recommend to add them as commands to your XMLSpy menu. SearchPath and CloseAllButActiveDoc. SearchPath opens a dialog where you get a list of all files currently in the project together with all other files open in XMLSpy. You can then type a search string and the list is reduced to the ones which match (case in-sensitive, substring search). CloseAllButActiveDoc does what it says. With one click all documents but not the active one are closed.

Just use the Customize dialog from the Tools menu to add the macros as commands:

Customize dialog in XMLSpy

Customize dialog in XMLSpy

Use the “Display text” field to give the command a friendly name. Do the same for the SearchPath macro and then go to the Keyboard tab to assign a keyboard accelerator for easy access. After I did that my Tools menu in XMLSpy looks like this:

Modified Tools menu

Modified Tools menu

Don’t be confused about the “Umschalt+Alt+S”. Umschalt just means Shift on a German system.

I can just recommend to check-out the new scripting tool in XMLSpy. With the help of a few macros this excellent XML editor can be even better…

Share/Save/Bookmark

Today I read by chance a post in the oXygen XML editor forum (here) if it is possible to get the XSL which is used in the last step of Schematron validation to validate the XML instance. To make it short: in oXygen there is no special functionality for it, with ValidatorBuddy in XMLSpy you get it with one click.

Some background: Usually, to validate a XML instance document using Schematron a XSL stylesheet which is generated from the Schematron schema is applied to the input XML. To generate the XSL to validate the XML another XSL stylesheet that implements the Schematron definition is used. In addition you also need to do some pre-processing to resolve the includes at least. Guess what, this is also done with the help of a stylesheet.

To simplify this for the user and to save time XML ValidatorBuddy has a button to get the final XSL used to validate the XML with one click:

 

Get XSLT button for Schematron

Get XSLT button for Schematron

On the upper-right corner you can see the “Get XSLT” button. If a Schematron stylesheet is assigned to the XML a new .xsl document will be created in XMLSpy with the stylesheet to validate any instance document.

You can then save this stylesheet and apply it to any XML with simple XSL transformation or you can use it to debug the Schematron schema in the built-in debugger of XMLSpy.

Share/Save/Bookmark

, , ,