xsl-list
[Top] [All Lists]

Re: template match : node-set paring through multiple-axis relationships

2003-06-04 07:46:39



I am glad you said something about the variables.  If I set a variable value
through a select, and then test that variable, I had thought it would be the
same as substituting the node-set that the variable represents.  Is this the
case?

yes but a node set is a value, not an expression, so
if you go
<xsl:variable name="x" select="foo"/>

<xsl:for-each select="/a/b/c[$x]"/>

it is _not_ the same as going

<xsl:for-each select="/a/b/c[foo]"/>


which would evaluate the node set resulting from foo in the context of
each c node in turn.


<xsl:for-each select="/a/b/c[$x]"/>

is exactly the same as going

<xsl:if test="foo">
  <xsl:for-each select="/a/b/c">

as $x is a constant expression so can be factored out of the loop.


The "[//" match is strange, but I do not think too strange for the purpose.
by starting the predicate with // you are making it independent of the
current node, so again it would be more readable if you took it out of
the path expression and moved it to an xsl:if on the outside, it has the
same effect.

If you have any other suggestions or comments, I would appreciate them.  I
confess it is a very difficult problem to explain (and - I think - to
solve), but it should (in theory) be easier to so

A small input and a small expected output usually helps.

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
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list