Subject: RE: [xsl] Variables and the mode attribute in apply-templates From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 3 Nov 2005 15:11:18 -0000 |
Nice try, a sort of double-polymorphism where the template to be executed depends on two nodes rather than just one... You could try <xsl:apply-templates select="/content/layout/node()"> <xsl:with-param name="p" select="xxx"/> </xsl:apply-templates> to call some kind of routing template which then applies templates to $p in a particular (fixed) mode. This feels to me like currying of functions, so it might be worth looking at Dimitre Novatchev's FXSL library and seeing if that offers anything that appeals. The reason it doesn't work of course is that in any language there are some places where you can use variables and some where you can't. You can't dynamically compute the name of a function or template to be called, the name of a mode, the name of a variable to be evaluated, the URI of a stylesheet module to be included, the name of a type to use in an "instance of" test, the text of an XPath expression to be evaluated, or the name of the instruction that you want to execute next. Most of these get requested from time to time (except the last - I made that one up). That's not to say that none of these are potentially useful; though in my view higher-order functions would meet most of the needs much more cleanly, and that's what FXSL is offering. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: ben senior [mailto:ben@xxxxxxxxxxxxx] > Sent: 03 November 2005 14:27 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Variables and the mode attribute in apply-templates > > I wish to decide between calling one of a set of templates > depending on > a fragment of xml (/content/layout/node()). > > Rather than having a mass of xsl:when/choose statements, I thought I > would add : > > <xsl:apply-templates select="xxx" mode="{/content/layout/node()}"/> > > That didn't work. I then tried setting an xsl:variable and doing > mode="$layout" and that didn't work. > Then I tried setting the mode attribute using xsl:attribute and that > didn't work. > > Am I missing out on something at the conceptual level - is this to do > with xsl's statelessness? > > Regards, > > Ben
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] access the root element, Michael Kay | Thread | Re: [xsl] Variables and the mode at, Dimitre Novatchev |
Re: [xsl] Variables and the mode at, David Carlisle | Date | RE: [xsl] Recursion problem with Fi, Michael Kay |
Month |