Subject: Re: [xsl] design question on function namespaces From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 4 May 2005 10:53:44 +0100 |
> How did she get that through the WG? I don't know (not being there) but one advantage is that it simplifies the introduction xsl:function as a function body can be exactly the same as a template body, the only difference between a function and a template is the calling convention. If you take the view that a template body always generates a fragment of a result tree then (as happened in the first drafts of xslt2, and in the exslt and saxon function extensions for xslt1) a function definition body looks like a template body but needs special rules or a special return instruction to allow atomic values rather than nodes of a tree to be returned. With the model as described by Michael, function bodies don't just look like template bodies, they are really the same construct. Actually it works fairly naturally on xsl:template. The place where the strain with doing this and maintaining an XSLT1 look and feel shows most strongly is on xsl:variable which already in XSLT1 had a switch to allow it to be bound to a tree fragment or an atomic value, namely the absence or presence of a select attribute. In the new model you also need to be able to use xsl:variable with content but return an atomic value rather than a tree fragment, so xsl:variable gets the as attribute: note Michael's example: <xsl:variable name="x" as="xs:boolean"> <xsl:apply-templates select="chap" mode="doc:has-footnotes"/> </xsl:variable> without the as=".." there $x would hold a document node with child a text node with the string value of teh result of calling teh template ("treu" or "false"). Again this works out OK in practice but the edge cases of having or not having select or as attributes, or having or having content can catch you out if you are not careful, especially with default values for parameters. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] design question on functi, Pawson, David | Thread | RE: [xsl] design question on functi, Michael Kay |
[xsl] Help with the xsl stylesheet , Seng Kiat Lim | Date | RE: [xsl] design question on functi, Michael Kay |
Month |