xsl-list
[Top] [All Lists]

How to: Reference to the current Nodeset while processing through another one

2004-09-29 01:41:53
Hello List,

I'm having the following XML structure:

<XML>
        <Value id="123">
                <aNode>bla</aNode>
        </Value>
        <Value id="123">
                <aNode>bla bla</aNode>
        </Value>
        <Value id="321">
                <aNode>blub</aNode>
        </Value>
</XLM>

How you can see I ve got a pretty flat hierarchy. In this case I ve got
nothing else than 3 Values, each having a child node "aNode". Two of the
"Value" items having a "id" with a value of "123", one having "321". 
This is just a simplification of the mush more complex XML strucure I really
have, so the following question might make no real sence with the XML above.
But it can show what my question is all about, I hope :)

While processing a Nodeset "Vakue" having a attribut "id" with a value of
"123", I want to get all other "Value" items, having the same id. I want to
get them without using a referenc variable.

I tried:
<xsl:for-each select="//Value[(_at_)id = Value/@id]">
        <!-- Do something -->
</xsl:for-each>

But this returned all Values having a attribut "id".

If I declare a variable with the value of "id"
<xsl:variable name="v_id">
        <xsl:value-of select="@id"/>
</xsl:variable>

and process though the other nodes by using the variable it works:
<xsl:for-each select="//Value[(_at_)id = $v_id]">
        <!-- Do something -->
</xsl:for-each>

In this case I get all "Value" nodes having a "id" of "123".
But how can I do this without using a variable? 
I m builing a processing variable this way, and do'nt want to define other
global variables just for 
building another one.

Thanks a lot!
Jan


<Prev in Thread] Current Thread [Next in Thread>