Subject: Re: [xsl] Variable scope when using imported stylesheets From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 24 Aug 2004 15:59:19 +0100 |
> Of course, this means I have to insert the variables > declaration in every template that is called in this way. If evaluating the variable is likely to be expensive an alternative is to pass it as a parameter, so after your top level template that is processing your document fragment you evaluate the variable then pass it as a parameter (you would have to declare it and pass it explicty in every template that is used though). Alternatively of course you can use XML entity references which can be used to hold arbitrary fragments of expressions (just as in C you can't hold an expression in a string valued variable but you can use a #Define as that is expanded inline by the pre-processor). If you just want a short way to access the Xpath expression you can do <!DOCTYPE xsl:stylesheet [ <!ENTITY foo "a/b/c/d/e/f/g/h/i/j/k/l/m[67]"> ]> <xsl:stylesheet> .... <xsl:apply-templates select="&foo;"/> .... <xsl:apply-templates select="&foo;"/> here the entity reference will be expanded by the parser before XSLT begins so XSLT will see <xsl:stylesheet> .... <xsl:apply-templates select="a/b/c/d/e/f/g/h/i/j/k/l/m[67]"/> .... <xsl:apply-templates select="a/b/c/d/e/f/g/h/i/j/k/l/m[67]"/> and each of the expressions will be evaluated in the context in which it appears. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. 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] Variable scope when using, Ralph Holz | Thread | Re: [xsl] Variable scope when using, Wendell Piez |
Re: [xsl] Variable scope when using, Ralph Holz | Date | RE: [xsl] apply template, Vasu Chakkera |
Month |