Schema validation of XSLT, SVG, XPath : Part 1 Proposal for lists
Curt.Arnold at hyprotech.com
Wed Dec 8 17:20:17 GMT 1999
A few weeks ago, Tim Berners-Lee strongly suggested that other XML
technologies start using XML Schema.
I have reviewed several of the other XML technologies and believe with some
minor enhancements, XML Schema can do effective validation of these
technologies. I've broken up the necessary modifications into several
different messages, so that each can be independently considered and
reviewed, however I see all of them as necessary, reasonable and easy to
implement with minimal additional effort. I would appreciate any comments.
The following note was written after reviewing XSLT but before reviewing
SVG. SVG makes much more extensive use of lists and so I believe its adds
even more compelling justification for the proposal.
The datatype draft explicitly defers addressing compound types to the next
revision of Schema, however I believe that lists are so essential to
validating these significant XML technologies and so generally useful that
they should be addressed in the initial recommendation.
In XSLT, there are numerous uses of space separated lists, two of which
cannot be addressed with the DTD compatibility NMTOKENS list type. This
message identifies them, proposes an additional element for XML Schema
Datatypes that would address delimited lists in a minimally distruptive
manner that would be generally useful and then presents schema fragments for
the XSLT elements.
I believe this is a compelling (even demanding) argument for inclusion of
list support in the initial version of XML Schema.
1. List usage in XSLT:
extension-element-prefixes = tokens
exclude-element-prefixes = tokens
<xsl:strip-space elements = nameTests
<xsl:preserve-space elements = nameTests
<xsl:element use-attribute-sets = qnames // qname could be done with
<xsl:attribute-set use-attribute-sets = qnames
<xsl:copy use-attribute-sets = qnames
<xsl:output cdata-section-elements = qnames
Only the strip-space and preserve-space elements could not be done with
NMTOKENS, since a nameTest can have '*' and other non-name characters.
However, there would also be value in capturing the fact that qnames and
that extension-element-prefixes should be unqualified names.
Pattern is a list of LocationPathPatterns. However, since
LocationPathPattern is not used separately, the value of having a
LocationPathPattern datatype and Pattern as a list of LocationPAthPattern is
RelativePathPattern would appear to be a list of StepPatterns, however since
the delimiter used ("/" or "//") is significant they would not be
appropriate to treat as a generic list.
2. Proposed solution:
a) Add list element to schema (uses char datatype defined later) -->
<attribute name="minOccurs" datatype="non-negative-integer"
<!-- absent of separator attribute means no separator
<attribute name="separator" basetype="char"/>
<!-- default value (false) means that items can be
separated by only the separator (if any)
true would be useful for comma deliminated lists that
have non-significant white space -->
<attribute name="ignoreExcessWhitespace" datatype="boolean"
b) add to datatype element and dataQual archetype
c) Add a couple of new built-in datatypes (though not essential, but
generally useful). (These are also replicated in a following comment on
<!-- use of qname could result in namespace expansion in type aware
<!-- disallow : character, basetype takes care of assuring nmtoken
d) remove special narrative about NMTOKENS and IDREFS and redefine NMTOKENS
and IDREFS as:
3. Use of list element in XSLT schema
<!-- I'm going to make a separate note on multiple literal Reps
basically it means that as long as I match one of the
I'm acceptible -->
<attribute name="elements" datatype="nameTests"/>
The following seems a reasonable processing mechanisms for list (when
separator="," for clarity)
complete production pattern for basetype
if ignoreWhitespace is true
match the following regex [&x0A&0x09&0x0D ]*,[&x0A&0x09&0x0D ]*
loop while there is a match
5. Examples of processing
<element name="nonsense" datatype="strings"/>
Processing any fragment (including the following):
<nonsense>This, is, only, has, one, item, since, nothing, terminates, the,
will return a one item list since nothing terminates the string production.
<element name="nonsense" datatype="quotedStrings"/>
Processing the following fragment will result in two items
<nonsense>"I can have my separator (,) in here since","nothing had
terminated my production"</nonsense>
The comma in parenthesis is not processed as an item separator since it was
encountered in the scope of the production pattern for quoted string.
<element name="nonsense" datatype="floats"/>
Processing the following fragment:
<nonsense>3.1415926, 2.718, 1.414</nonsense>
Would result in a validation error, since the space between the first comma
and second number does not match the float production. If the list element
had been <list separator=","/>, then it would return 3 items.
Would also be a validation error, since the null string between the two
comma's does not match the float production.
6. Accessing lists through a type-aware DOM
I definitely think that trying to define how a type-aware DOM would access
provide access to list data is outside the scope of the schema work.
However, it would not appear that adding generic lists would add any new
issues to that work project since
they would have to address how to provide access to the compatibility lists
of NMTOKENS and IDREFS. There solution to that problem could be as easy as
saying that their is no native type support for lists and you can only get
the entire string back. However you will have been assured that the string
meets your production requirements.
7. Additional burden on schema validation code
I believe the additional burden on validation authors would be minimal since
the generic list validation code can replace any IDREFS or NMTOKENS
validation code. I would appreciate any comments from the Xerces or other
schema parser initiative team on their accessment of the additional
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at ic.ac.uk the following message;
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev