RE: XML Schemas patterns (was: Re: Defining recursive elements?)

> 
> Speaking for myself, I think the more explicit forms such as 
> vehicleName seem to me to be better markup in most cases. 

It's interesting to ask whether vocabularies such as XSLT and XML Schema
follow the rule that a given element name or attribute name has the same
syntax and semantics wherever it appears.

XSLT has a few exceptions, for example xsl:param can appear in three
different places (as a child of xsl:stylesheet, xsl:template, or
xsl:function) and the rules are slightly different in each case, although we
don't actually try to model this in the schema.

XML Schema has more extreme examples, where the content model of
xs:restriction, for example, is very different depending on the context. 

I don't think I would condemn either of these as bad design. In both cases
the similarities outweigh the differences, and from a user perspective the
elements are performing the same function regardless of the context in which
they appear.

Your mention of simplifying XSLT coding suggests a wacky idea: it would be
nice if one could express the validation in terms of rules, for example:

<xs:validation match="xsl:param">
  <xs:complexType>
    ...
  </xs:complexType>
</xs:validation>

<xs:validation match="xsl:template/xsl:param">
  <xs:next-rule/>
  <xs:assert test="not(@required)"/>
</xs:validation>

<xs:validation match="xsl:variable[@select]">
  <xs:complexType>
    a content model ...
  </xs:complexType>
</xs:validation>

<xs:validation match="xsl:variable[not(@select)]">
  <xs:complexType>
    a different content model ...
  </xs:complexType>
</xs:validation>

Seems to unify type derivation, conditional type assignment, global vs local
elements, etc, etc.

Wouldn't it be fun to start again?

Michael Kay
http://www.saxonica.com/

Received on Friday, 18 May 2007 20:22:08 UTC