Re: [xsl] push-pull

Subject: Re: [xsl] push-pull
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 19 Mar 2008 10:01:24 GMT
> I think the only case where you can't tell statically is probably within a named
> template. I think it's probably good practice for a named template to
> declare a parameter:
> <xsl:param name="target" select="."/>
> and within the body of the template to refer to $target rather than
> ".".

Alternatively (and less intrusively if you are updating a bunch of xslt
1 templates to 2.0) It's fairly easy to ensure statically that the
context item is set before calling each named template. Essentially the
only place where it isn't set is at the top level in a function body, so
don't use xsl:call-template directly at that level, if inside a function
body always go
<xsl:for-each select="something">
  <xsl:call-template ...
for any template that might depend on the current context.

this is equivalent to Michael's suggestion of using
<xsl:call-template name=..
  <xsl:with-param name="target" select="something"/>

except you don't have to change all the relative xpaths in the template
body to start with $target.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

Current Thread