Re: [xsl] Matching attribute with condition in predicate

Subject: Re: [xsl] Matching attribute with condition in predicate
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Dec 2009 10:19:37 -0500
At 2009-12-22 18:13 +0300, PP8QP0P8P; P!P0P1QQP5P=P:P>P2 wrote:
2009/12/22 G. Ken Holman <gkholman@xxxxxxxxxxxxxxxxxxxx>:
>
> Because the "/" at the start of "/root/@condition" is the top of the
> _current tree_, not the top of the initial tree. B Thus it is at the top
of
> the tree with the attribute because it is in the predicate tested when
the
> attribute is the current node.
>
> You want a global variable something like:
> B <xsl:variable name="orig" select="/"/>
>
> ... and then in your predicate
@attr[$orig/root/@condition='ru'] in order to
> switch to the original tree from your temporary tree.

Thanks for quick reply.
Now I see why it's not working, but I can't use variables in
template/@match, can I ?

Forgive me, you can in XSLT 2.0 and I failed to notice you were running XSLT 1.0 (which I *should* have since you were using exslt!).

So I can't figure out how to get original tree there, and it seems
that I have to use choose/when/otherwise.

Since you are in charge of the temporary tree, can you just throw that original tree attribute as an attribute of the top of your temporary tree so that you can look at it at any time using "/*/@condition" (which doesn't care about the name of the document element of the current tree)?

. . . . . . . . . . Ken


-- UBL and Code List training: Copenhagen, Denmark 2010-02-08/10 XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19 XSLT/XQuery/XPath training: San Carlos, California 2010-04-26/30 Vote for your XML training: http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread