van der Vlist, Eric. “XML instances to validate XML schemas.” Presented at International Symposium on Quality Assurance and Quality Control in XML, Montréal, Canada, August 6, 2012. In Proceedings of the International Symposium on Quality Assurance and Quality Control
in XML. Balisage Series on Markup Technologies, vol. 9 (2012). https://doi.org/10.4242/BalisageVol9.Vlist02.
International Symposium on Quality Assurance and Quality Control in XML August 6, 2012
Balisage Paper: XML instances to validate XML schemas
Eric van der Vlist
Eric is an independent consultant and trainer. His domain of expertise include Web
He is the creator and main editor of XMLfr.org, the
main site dedicated to XML technologies in French, the author of the O'Reilly animal
Schema and RELAX NG and a member or the ISO DSDL (http://dsdl.org) working group focused on XML schema languages.
He is based in Paris and you can reach him by mail (email@example.com) or meet him in one of the many conferences where he presents his
Published under the Creative Commons "cc by" license
Ever modified an XML schema? Ever broken something while fixing a bug or adding a
new feature? As with
any piece of engineering, the more complex a schema is, the harder it is to maintain.
In other domains,
unit tests dramatically reduce the number of regressions and thus provide a kind of
safety net for
maintainers. Can we learn from these techniques and adapt them to XML schema languages?
In this workshop
session, we develop a schema using unit test techniques, to illustrate their benefits
The workshop is run as an exchange between a customer (played by Tommie Usdin) and
a schema expert (played by
Eric van der Vlist).
The customer, who needed a schema for her to-do list XML application, is puzzled by
the "test first programming"
technique imposed by the schema expert.
At the end of the day (or workshop), will she be converted to this well-known agile
or extreme programming
technique adapted to the development of XML schemas?
Step 1: Getting started
Hi Eric, can you help me to write a schema?
Hi Tommie, yes, sure, what will the schema be about?
I need a vocabulary for my to-do lists, with to-do item...
OK, you've told me enough, let's get started.
— Expert (interrupting his customer)
Get started? but I haven't told you anything about it!
Right, but it's never too soon to write tests when you do test first programming!
In test first programming (also called test driven development),
developers create test case (usually unit test cases) before implementing a function.
The test suite is
run, code is written based on the result of these tests and the test suite and code
are updated until
all the tests pass.
The vocabulary used to define these test cases has been inspired by the SUT (XML Schema Unit Test) project. It's a simple
vocabulary (composed of only three different elements) allowing to pack several XML
with the outcome validation result. It uses conventions that you'll discover during
the course of this
This is the first example with non-top-level tf:case elements. To understand how this
works, we must look in more detail to the algorithm used by the framework to split
a test suite into
instances. The algorithm consists in two steps:
Loop over each tf:case element
Suppression of the tf:case elements and of the top level elements which are
not ancestors of the current tf:case element.
This description may look complex, but the result is a rather intuitive way to define
sub-trees that are common to several test cases.
Now that we've updated the test suite, we run it again.
split-tests.xsl is the XSLT transformation that splits a test suite into top level
element test cases. This transformation has no dependence on Orbeon Forms and can
run against a test suite.
Copy the orbeon-resources/ directory under /WEB-INF/resources/apps/ in your
orbeon webapp directory
Or, alternatively, copy the tefisc/ directory wherever you want, edit web.xml.sav to replace
by the location of this directory on your filesystem, replace /WEB-INF/web.xml by
this file and restart your application server.