Subject: RE: [xsl] A beef with XSLT Sometimes too complicated From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 17 Jul 2006 19:05:23 +0100 |
> In line with the question whether to prefer XPath or XSLT > logic, can we see an example where we'd actually prefer to do > it in XPath if we could? (I'd welcome entries from anyone.) One case is a sort based on a lookup field: <xsl:sort select="$lookup[data=current()/@x]"/> current() here is a bit of a hack: it's in effect a built-in variable. It allows you to do a 2-way join without resorting to explicit variables, but fails when you want a 3-way join: <xsl:sort select="$lookup1[let $x:=. return data=$lookup2[data=$x/@x]]"/> In practice I've found that the variable you want to bind here is almost invariably bound to the context item, which means you can write it as <xsl:sort select="$lookup1[for $x in . return data=$lookup2[data=$x/@x]]"/> but it seems an ugly hack to use "for" to iterate over a singleton, just because you want to bind a variable. At one time I was trying to come up with some explicit syntax for binding the context item to a variable, for example <xsl:sort select="$lookup1[data = with $x do ($lookup2[data=$x/@x])]"/> but it's not significantly better than using "let $x:=.". Michael Kay http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] A beef with XSLT Sometime, Wendell Piez | Thread | Re: [xsl] A beef with XSLT Sometime, David Carlisle |
Re: [xsl] Fwd: Combing two differen, Mukul Gandhi | Date | Re: [xsl] Re: Keeping a running tot, Steve |
Month |