Looking up elements with {@attname}

Subject: Looking up elements with {@attname}
From: Klaas Bals <kbals@xxxxxxxxxxx>
Date: Sun, 23 May 1999 17:20:30 +0200
Hi,

I have some problems XSL... What I want to do is look up an element in a
template-rule when its attribute is the same as an attribute of the
current element. I'll try to give a simplified example:

<element att2="same-value" att3="firstvalue"/>
<element att2="same-value" att3="secondvalue"/>

<xsl:stylesheet>
    <xsl:template match="element">
        <xsl:value-of select="@att3"/>
        <xsl:text> found </xsl:text>
        <xsl:value-of select="//element[@att2={./@att2}]/@att3"/>
    </xsl:template>
</xsl:stylesheet>

I would like as output:
-----------
firstvalue found secondvalue
secondvalue found firstvalue
-----------

If the stylesheet above would be valid, I think I would get the correct
output, but the problem is that the last "xsl:value-of" element isn't
valid. More specifically the part after the "=" sign {./@att2} is
invalid. LotusXSL complaints about that it should stand between quotes,
but when I put it between (single) quotes, LotusXSL will look for an
element with its att2="{./@att2}", with this string "{./@att2}" as the
value for attribute "att2".
I also tried with an xsl:variable element, but then it complaints about
the $varname that should stand between quotes...

Can somebody understand what I'm saying? This topic was perhaps
discussed before, if so, please point me to the URL where I can find
some information... I tried looking for an answer in the archives and
all xml-sites, but couldn't find a thing...

Thanks for your time!
Klaas



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


Current Thread