Thanks for the reply.
One more point. I re-wrote the key() function within the
<xsl:apply-templates> element.
Original
--------
<xsl:apply-templates select="key('x',addressbook/address/zip)" />
Modified
--------
<xsl:apply-templates select="addressbook/address[key('x', zip)]" />
This time it worked.
Respectfully,
ASP
-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Sent: Friday, May 13, 2005 5:39 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Question about the key() function
Because there is a bug in your XSLT processor. The correct output is:
Saxon 8.4 from Saxonica
...
<?xml version="1.0" encoding="UTF-8"?>
<keyNode>
<Name>1, Frisby, 48392</Name>
<Name>10, Backstayge, 02718</Name>
<Name>2, Attired, 00218</Name>
<Name>20, Backstayge, 02718</Name>
<Name>300, McGoon, 27318</Name>
<Name>31, Reckonwith, 02930</Name>
</keyNode>
The key() function is specified to remove duplicates, it appears your
implementation is not doing so.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: aspsa [mailto:aspsa(_at_)optonline(_dot_)net]
Sent: 13 May 2005 22:14
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Question about the key() function
Hi, folks.
Given this document...
<?xml version="1.0" encoding="UTF-8"?>
<addressbook>
<address>
<name>
<title>Mr.</title>
<first-name>Chester Hasbrouck</first-name>
<last-name>Frisby</last-name>
</name>
<street>1234 Main Street</street>
<city>Sheboygan</city>
<state>WI</state>
<zip>48392</zip>
<id>1</id>
</address>
<address>
<name>
<first-name>Mary</first-name>
<last-name>Backstayge</last-name>
</name>
<street>283 First Avenue</street>
<city>Skunk Haven</city>
<state>MA</state>
<zip>02718</zip>
<id>10</id>
</address>
<address>
<name>
<title>Ms.</title>
<first-name>Natalie</first-name>
<last-name>Attired</last-name>
</name>
<street>707 Breitling Way</street>
<city>Winter Harbor</city>
<state>ME</state>
<zip>00218</zip>
<id>2</id>
</address>
<address>
<name>
<first-name>Harry</first-name>
<last-name>Backstayge</last-name>
</name>
<street>283 First Avenue</street>
<city>Skunk Haven</city>
<state>MA</state>
<zip>02718</zip>
<id>20</id>
</address>
<address>
<name>
<first-name>Mary</first-name>
<last-name>McGoon</last-name>
</name>
<street>103 Bryant Street</street>
<city>Boylston</city>
<state>VA</state>
<zip>27318</zip>
<id>300</id>
</address>
<address>
<name>
<title>Ms.</title>
<first-name>Amanda</first-name>
<last-name>Reckonwith</last-name>
</name>
<street>930-A Chestnut Street</street>
<city>Lynn</city>
<state>MA</state>
<zip>02930</zip>
<id>31</id>
</address>
</addressbook>
...and this XSLT document...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:key name="x" match="address" use="zip"/>
<xsl:template match="/">
<keyNode>
<xsl:apply-templates select="key('x',addressbook/address/zip)" />
</keyNode>
</xsl:template>
<xsl:template match="address">
<Name>
<xsl:value-of select="id"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="name/last-name"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="zip"/>
</Name>
</xsl:template>
</xsl:stylesheet>
...why does the output repeat nodes containing id values 10 and 20?
<?xml version="1.0" encoding="UTF-8"?>
<keyNode>
<Name>1, Frisby, 48392</Name>
<Name>10, Backstayge, 02718</Name>
<Name>10, Backstayge, 02718</Name>
<Name>2, Attired, 00218</Name>
<Name>20, Backstayge, 02718</Name>
<Name>20, Backstayge, 02718</Name>
<Name>300, McGoon, 27318</Name>
<Name>31, Reckonwith, 02930</Name>
</keyNode>
Respectfully,
ASP
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--