[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Types and Context

  • From: Jeni Tennison <mail@j...>
  • To: Jonathan Borden <jborden@m...>
  • Date: Tue, 22 May 2001 09:14:05 +0100

xs types
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/



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.