[xslt] xsl:key pattern bug?
- From: Bob Stayton <bobs caldera com>
- To: xslt gnome org
- Subject: [xslt] xsl:key pattern bug?
- Date: Tue, 29 Jan 2002 16:15:52 -0800
I've run into an odd little problem that I think is
an xsltproc bug, or it could be my misunderstanding of xsl:key's
'match' attribute. It appears that the '|' union operator
in the xsl:key match attribute isn't always handled correctly.
I have two elements that use an 'id' attribute
that I want my key to index. Here is the
test stylesheet:
<?xml version='1.0'?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
<xsl:key name="mykey" match="div|obj" use="@id" />
<xsl:template match="link">
<xsl:value-of select="@linkend"/>
<xsl:text> </xsl:text>
<xsl:value-of select="key('mykey', @linkend)/@href" />
</xsl:template>
</xsl:stylesheet>
Here is a small sample document:
<?xml version="1.0" encoding="ISO-8859-1"?>
<div id="div111" href="div111href">
<div id="div222" href="div222href" >
<obj id="obj333" href="obj333href" ></obj>
</div>
<link linkend="div111"/>
<link linkend="div222"/>
<link linkend="obj333"/>
</div>
The output should be:
div111 div111href
div222 div222href
obj333 obj333href
The output actually is:
div111 div111href
div222 div222href
obj333
(This is using libxml2-2.4.12, libxslt-1.0.9, Linux)
At first I thought it was just ignoring the element 'obj'
after the union operator, but when I change the order
in the key to use match="obj|div", my output is:
div111 div111href
div222
obj333 obj333href
This is even stranger, as it missed the nested div element
this time. My understanding is that the match attribute
uses a pattern, similar to xsl:template.
Is this a bug?
--
Bob Stayton 400 Encinal Street
Publications Architect Santa Cruz, CA 95060
Technical Publications voice: (831) 427-7796
Caldera International, Inc. fax: (831) 429-1887
email: bobs@caldera.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]