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/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format