RELAX NG by Eric van der Vlist will be published by O'Reilly & Associates (ISBN: 0596004214)
You are welcome to use our annotation system to give your feedback.
Despite similarities on the surface, the pattern facet interprets its value in a very different way than value does. value reads the value as a lexical representation, and converts it to the corresponding value for its base datatype, while pattern facet reads the value as a set of conditions to apply on lexical values. When we write:
pattern="15" |
we specify three conditions (first character equals "1", second character equals "5", and the string must finish after the 5). Each of the matching conditions (such as first character equals "1" and second character equals "5") is called a piece. This is just the simplest form for specifying piece.
Each piece in a pattern facet is composed of an atom identifying a character, or a set of characters, and an optional quantifier. Characters (except special characters which must be escaped) are the simplest form of atoms. In our example, we have omitted the quantifiers. Quantifiers may be defined using two different syntaxes: either using special characters ( * for 0 or more, + for one or more, and ? for 0 or 1) or a numeric range within curly braces ({n} for exactly n times, {n,m} for between n and m times, or {n,} for n or more times).
Using these quantifiers, we can merge our three pattern facets into one:
<data type="byte"> <param name="pattern">1?5?</param> </data> |
Or:
xsd:byte {pattern = "1?5?"} |
This new pattern facet means there must be zero or one character ("1") followed by zero or one character ("5"). This is not exactly the same meaning as our three previous pattern facets since the empty string "" is now accepted by the pattern facet. However, since the empty string doesn't belong to the lexical space of our base type ( xsd:byte), the new datatype has the same lexical space as the previous one.
We could also use quantifiers to limit the number of leading zeros--for instance, the following pattern facet limits the number of leading zeros to up to 2:
<data type="byte"> <param name="pattern">0{0,2}1?5?</param> </data> |
Or:
xsd:byte {pattern = "0{0,2}1?5?"} |
You are welcome to use our annotation system to give your feedback.
[Annotations for this page]
All text is copyright Eric van der Vlist, Dyomedea. During development, I give permission for non-commercial copying for educational and review purposes. After publication, all text will be released under the Free Software Foundation GFDL.