[xsl] efficient use of key element and function

Subject: [xsl] efficient use of key element and function
From: Manfred Staudinger <manfred.staudinger@xxxxxxxxx>
Date: Tue, 6 Sep 2005 20:26:49 +0200
Hi all,
Given a rather long list of unique names I want to know for a
certain name if it is on that list. The stylesheet below does
this, but is this the best (most efficient) solution? In the most
common case around 95% of the names will be found.
- is the key element correct (I have no use for @use)?
- should I sort the names?

In the real stylesheet the names represent files and are used
to avoid a file-not-found for doc(). They are retrieved by means
of collection().

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
<xsl:key name="find" match="*" use="."/>
<xsl:template match="/">
<xsl:variable name="Index-alt">
<xsl:value-of select="empty(key('find', 'prunauer_regina', $Index-alt))"/>
<xsl:value-of select="empty(key('find', 'strada_jacopo', $Index-alt))"/>

Regards, Manfred

Current Thread