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

RE: design question on function namespaces

Subject: RE: design question on function namespaces
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 4 May 2005 09:04:59 +0100
RE:  design question on function namespaces
>     <xsl:template match="open-office:chapter" 
>     mode="doc:chapter-has-footnotes"
>     as="xs:boolean">
>       <xsl:sequence select="exists(.//footnote)"/> </xsl:template>
> 
> 1. Return the boolean value to whom | what?
> 

To its caller. For example,

<xsl:variable name="x" as="xs:boolean">
  <xsl:apply-templates select="chap" mode="doc:has-footnotes"/>
</xsl:variable>

If the call on apply-templates returns a boolean, that boolean will be the
value of variable $x.

We all tend to think in terms of the 1.0 model where XPath expressions read
the source document and XSLT instructions write to the result tree. Thanks
largely to Jeni Tennison's intervention half way through the 2.0 design
process, that's no longer the processing model: instructions and expressions
now both return results to their caller, and the result can be any sequence
of atomic values or nodes.

There are basically two ways of getting the result of an XSLT instruction
back into the XPath world to make it available for further processing: you
can assign it to a variable, as above, or you can return it as the result of
a function, as in my earlier example:

<xsl:function name="doc:has-footnotes" as="xs:boolean">
  <xsl:param name="chap" as="element()"/>
  <xsl:apply-templates select="$chap"/>
</xsl:function> 

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

Current Thread

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
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-2013 All Rights Reserved.