- From: Oleg Tkachenko <olegt@multiconn.com>
- Date: Thu, 20 Dec 2001 17:51:39 +0200
- To: xsl-editors@w3.org
Stanislav Vitebskiy wrote:
> Here is a simple problem: select all the <customer> elements
> that have <employee> sibling with the same 'name' attribute.
> The solution is pretty obvious:
> customer[@name = ../employee/@name]
>
> Lets now complicate the task a little. Let the name consist of
> two parts, 'first-name' and 'last-name'.
> Little complication - big problem: the technique shown above
> will no longer work; there is no way to compare more than one
> attribute of different elements, and there is no workaround in
> the current version of XPath.
current() function may be helpful to a certain extent, consider current
node is customer element:
self::*[../employee[@first-name=current()/@first-name
and @last-name=current()/@last-name]]
may be it's not too handy, but actually it is grouping problem and keys
would be more elegant and effective solution:
<xsl:key name="kEmpName" match="employee" use="concat(@first-name, '-',
@last-name)"/>
...
<xsl:apply-templates select="customer[key('kEmpName',
concat(@first-name, '-', @last-name))]"/>
--
Oleg Tkachenko
Multiconn International, Israel
Received on Thursday, 20 December 2001 14:34:23 UTC