Subject: RE: [xsl] design question on function namespaces From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 4 May 2005 09:04:59 +0100 |
> <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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] design question on functi, Pawson, David | Thread | RE: [xsl] design question on functi, Pawson, David |
RE: [xsl] design question on functi, Pawson, David | Date | [xsl] XPath Expression to Extract, Manjunath N.S. |
Month |