Index: doc/schema.html ================================================================== --- doc/schema.html +++ doc/schema.html @@ -2,22 +2,22 @@
+
tdom::schema -
Creates a schema validation command
package require tdom +SYNOPSIS
package require tdom tdom::schema ?create? cmdName-DESCRIPTION
Every call of this command creates a new validation command. A +
DESCRIPTION
Every call of this command creates a new validation command. A validation command has methods to define a schema and is able to validate XML data or to post-validate a tDOM DOM tree (and to some degree other kind of hierarchical data) against this schema.
Also, a validation command may be used as argument to the -validateCmd option of the dom parse and the @@ -345,11 +345,11 @@
For more detailed information see section Recovering.
+For more detailed information see section Recovering.
Schema definition scripts are ordinary Tcl scripts evaluated in +
Schema definition scripts are ordinary Tcl scripts evaluated in the namespace tdom::schema. The schema definition commands listed below in this Tcl namespace allow the definition of a wide variety of document structures. Every schema definition command establishes a validation constraint on the content which has to match or must be optional to qualify the content as valid. It is a @@ -879,11 +879,11 @@ another definition script command and will raise error, if you call it there. -
Several schema definition commands expect a quantifier as +
Several schema definition commands expect a quantifier as one of their arguments which determines how often the content particle specified by the command is expected. The valid values for a quant argument are:
If an optional quantifier is not given, it defaults to * in case of the mixed command and to ! for all other commands.
-Text (parsed character data, as XML calls it) sometimes has to +
Text (parsed character data, as XML calls it) sometimes has to be of a certain kind or comply with certain rules to be valid. The text constraint script arguments to text, attribute, nsattribute and deftexttype commands are evaluated in the Tcl namespace tdom::schema::text namespace and allow the ensuing text constraint commands to check text for certain properties. The @@ -942,11 +942,11 @@ argument list. They return a logical value. Please note that the commands may not accept starting or ending white space. If a command is available in the tdom::type namespace is recorded in its documentation.
-The tcl text constraint command dispatches the check to an arbitrary Tcl command, thus enable any programmable decision rules.
Document wide uniqueness and foreign key constraints are +
Document wide uniqueness and foreign key constraints are available with the text constraint commands id and idref. Keyspaces allow for sub-tree local uniqueness and foreign key constraints.
By default the validation engine stops at the first detected +
By default the validation engine stops at the first detected validation violation and reports that finding. It does so by return false (and sets, if given, the result variable with an error message) in case the schema command itself is used to validate input. If the schema command is used by a SAX parser or the DOM parser, it does so by throwing error.
If a reportcmd is set this command is called on global @@ -1466,11 +1466,11 @@ contraint and continues to match the event further against the schema.
Returning "vanish" from the recover script in case of the error types MISSING_ELEMENT and UNEXPECTED_ELEMENT recovers by ignoring the event.
-The XML Schema Part 0: Primer Second Edition +
The XML Schema Part 0: Primer Second Edition (https://www.w3.org/TR/xmlschema-0/) starts with this example schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> @@ -1535,11 +1535,11 @@ <xsd:pattern value="\d{3}-[A-Z]{2}"/> </xsd:restriction> </xsd:simpleType> </xsd:schema> -
A likely one-to-one translation of that into a tDOM schema +
A simple one-to-one translation of that into a tDOM schema definition script would be:
tdom::schema schema schema define { # Purchase order schema for Example.com. @@ -1563,21 +1563,21 @@ element name element street element city element state element zip ! {text number} - attribute country ! {fixed "US"} + attribute country {fixed "US"} } defelement items { element item * { element product - element quantity ! {text integer} + element quantity ! {text positiveInteger} element USPrice ! {text number} element comment element shipDate ? {text date} - attribute partNum ! {pattern "^\d{3}-[A-Z]{2}$"} + attribute partNum {regexp "^\d{3}-[A-Z]{2}$"} } } }
The RELAX NG Tutorial @@ -1635,13 +1635,13 @@ } } -
+