Re: [xsl] How to specify a path to a node in a nodeset using a variable

Subject: Re: [xsl] How to specify a path to a node in a nodeset using a variable
From: "Shakeel Mahate" <shakeelmahate@xxxxxxxxxxx>
Date: Sun, 11 Mar 2001 19:08:28 -0500
David Carlisle <davidc@xxxxxxxxx> and Mike Kay had the following suggestion:

>> Somebody who reads my code will have a tough time figuring out that the
>> <xsl:for-each...> is there simply to change the current nodeset.
>
>possibly not as that's one of the more common uses of for-each
>(especially with key() or id())
>
>however if you don't want to do that, don't you just want
>
>select="xalan:evaluate(concat('$container/',$path))"/>

I think I am missing some concept or maybe I have not explained myself
clearly.

Let's dissect XSLT function concat, it concatenates two strings.

If the arguments being passed are something other than strings, then the
XSLT processor automatically converts them into strings.

In my scenario, $container is a nodeset, not a nodeset expression.

$path is a string, that happens to contain an XPath expression.

If were to concat $container and $path, what would happen here?

String value of the $container nodeset and the string value of the $path.

Now when I invoke xalan:evaluate(string), it tries to evaluate the string
parameter as an XPath expression and apply it to the current nodeset.  The
current nodeset is the nodeset of the template or the for-each construct.

Am I in the ballpark?

David, also suggested, that using for-each construct is OK for changing the
current nodeset.

>possibly not as that's one of the more common uses of for-each

I also would like to question the XSLT community and ask why should we live
with this way of looking at the problem.

Why can't we have a construct specifically for changing the current nodeset,
in my previous email I gave two alternatives.

Alternative 1:  An optional parameter "apply-to" on xsl:call-template.
    <xsl:call-template name: "template1" apply-to: "nodeset"/>

Alternative 2:  An optional parameter nodeset to the xalan:evaluate
function.

Does this mailing list apply only to saxon?  Should I be posting somewhere
else for Xalan.

Is somebody from the Xalan community listening?

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


Current Thread