[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Types and Context
- From: Jeni Tennison <mail@jenitennison.com>
- To: Jonathan Borden <jborden@mediaone.net>
- Date: Tue, 22 May 2001 09:14:05 +0100
Hi Jonathan,
> Exactly. And if you stop to think about this, XML Schema "datatypes"
> are hardly going to revolutionize XSLT/XPath 2.0.
While I agree, given the example that you gave, surely the point of
getting datatypes in XSLT/XPath would be most obvious in conditions
where you have two elements that share the same type, either directly:
<xs:element name="mother" type="this:person" />
<xs:element name="father" type="this:person" />
Or indirectly:
<xs:element name="director" type="this:director" />
<xs:complexType name="director">
<xs:extension base="this:person">
...
</xs:extension>
</xs:complexType>
<xs:element name="employee" type="this:employee" />
<xs:complexType name="employee">
<xs:extension base="this:person">
...
</xs:extension>
</xs:complexType>
Here, the fact that this:mother and this:father share a type means
that they can be processed in the same way. In XSLT/XPath currently,
we would encode that by having them both matched by the same template.
But it would be more extensible if we had a way of matching *all*
elements of the this:person type instead:
<xsl:template match="*[xs:type('this:person')]">
...
</xsl:template>
New elements of the this:person type that were added to the schema
would automatically be matched by this template, whereas in the
current situation I'd have to change the XSLT.
In the second example, something like the XSLT 2.0 requirement 2.17
for xsl:next-match (or similar) [1] could be really useful to help
me use the XML Schema type hierarchy to write modular XSLT:
<xsl:template match="*[xs:type('this:person')]" priority="-1">
... output for all people ...
</xsl:template>
<xsl:template match="this:director">
<!-- apply the next matching template to this node -->
<xsl:next-match />
... output for directors ...
</xsl:template>
Or at least that's how I imagined it.
Cheers,
Jeni
[1] http://www.w3.org/TR/xslt20req
---
Jeni Tennison
http://www.jenitennison.com/