Summary
XML Document Validator is a Java based implementation of CLiXML - Constraint Language in XML. It allows to express complex constraints about XML content using a mixture of first order logic and XPath.
CLiXML is much more powerful that XML-Schema or RelaxNG and simpler to understand and use than Schematron.
Visit Project Home Site for more information - http://sites.google.com/site/xmlxdv
Key features
- Java API (Java 1.5).
- Many errors in one go - validation does not stop at first constraint violation but reports as many errors in one run as possible.
- Switchable XPath engine - implementation is not bound to any XPath engine. XPath functionality has been extracted into a separate, independent package and can be easily replaced. Project provides ready to use connectors to Jaxen and Saxon 6.5.5.
- Dynamic error messages - an error message can include information extracted from XML node being tested by the rule.
More information
- http://www.clixml.org - CLiXML language definition
- http://sites.google.com/site/xmlxdv - Project Home Site with a detailed description, examples etc.
Example
XML document to validate:
<?xml version="1.0"?>
<device>
<actions>
<action name="execute"/>
</actions>
<events>
<event trigger="onFirstCall" actionNameRef="execute"/>
<event trigger="onCall" actionNameRef="execute"/>
</events>
</device>A sample rule expressed in CLiXML:
<?xml version="1.0"?>
<rules xmlns="http://www.clixml.org/clix/1.0">
<rule id="R1">
<header>
<author>Tomasz Kokoszka</author>
<description>
Action cannot be orphan - there has to be at least one event referring to it.
</description>
</header>
<report>Orphan action</report>
<forall var="actionName" in="/device/actions/action/@name">
<exists var="e" in="/device/events/event[@actionNameRef=$actionName]"/>
</forall>
</rule>
</rules>