http://www.di.uminho.pt/~jcr/PROJS/xcsl-www/
José Carlos Ramalho | jcr@di.uminho.pt | http://www.di.uminho.pt/~jcr |
Giovani Rubert Librelotto | grl@di.uminho.pt | http://www.di.uminho.pt/~grl | Marta Jacinto | marta.jacinto@itij.mj.pt | http://www.martajacinto.com |
Pedro Rangel Henriques | prh@di.uminho.pt | http://www.di.uminho.pt/~prh |
XCSL, XML Constraint Specification Language, is a domain specific language conceived with the purpose of allowing XML designers to restrict the content of XML documents. It is a simple, and small language useful to write contextual constraints over the textual value of XML elements and attributes.
Basically, the language provides the constructors necessary to define the actions to be taken by a semantic validator. Those actions will triggered whenever a boolean expression, over the value of the attributes or the content of the elements, evaluates to false. It means that XCSL also designates a processor that traverses the document’s internal representation (the tree) and checks its correctness from a semantic point of view (we shall stress that the structural correctness is validated by the parser that builds the tree).
Moreover, XCSL is an XML language; so it becomes possible to add restrictions to XML documents using an XML dialect. That approach offers document designers a complete XML framework to couple with syntax and semantics. The benefits of such an approach are obvious.
A specification in XCSL is composed by one or more tuples. Each tuple has three parts [Ramalho and Henriques, 1998]:
In a more formal notation we can write:
ConstraintSpec = Constraint+
Constraint = (ContextSelector, ContextCondition, Action)
We could
use a grammar to define the language, but as we stated before, we
decided to use XSLT to specify the constraints; in order to be
coherent, we needed an XML wrapper for the XSLT expressions (like
in XSL). So, each XCSL specification is defined as an XML instance
and the XCSL language is defined by a DTD (or an XML-Schema); the
present version of the DTD that specifies XCSL (named xcsl.dtd) is
shown below.
<?xml version="1.0" encoding="UTF-8"?> <!-- XCSL: XML Constraint Specification Language --> <!ELEMENT CS (CONSTRAINT)+> <!ATTLIST CS DTD CDATA #IMPLIED DATE CDATA #IMPLIED VERSION CDATA #IMPLIED > <!ELEMENT CONSTRAINT (SELECTOR, LET*, CC, ACTION)> <!ELEMENT SELECTOR EMPTY> <!ATTLIST SELECTOR SELEXP CDATA #REQUIRED > <!ELEMENT LET EMPTY> <!ATTLIST LET NAME CDATA #REQUIRED VALUE CDATA #REQUIRED > <!ELEMENT CC (#PCDATA | VARIABLE)*> <!ELEMENT VARIABLE EMPTY> <!ATTLIST VARIABLE SELEXP CDATA #REQUIRED > <!ELEMENT ACTION (MESSAGE*)> <!ELEMENT MESSAGE (#PCDATA | VALUE)*> <!ELEMENT VALUE EMPTY> <!ATTLIST VALUE SELEXP CDATA #REQUIRED > |
Nowadays, XML-Schema has overcome DTDs as a definition of classes for XML instances according to what was said before. We also made that upgrade, however, as XML-Schema is much more verbose than the correspondent DTD, we decided to include here the DTD and just a diagrammatic description of the XCSL XML-Schema. That diagram is shown in Figure 2, as obtained with the XML Spy 4.1, from Altova.
Index