This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: SUMMARY: Selecting unique value of an attribute
- To: xsl-list at mulberrytech dot com
- Subject: Re: SUMMARY: Selecting unique value of an attribute
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- Date: Thu, 24 Aug 2000 04:25:36 -0700 (PDT)
- Reply-To: xsl-list at mulberrytech dot com
You'll speed up the first solution considerably if you use
<xsl:if test="not(@entry = preceding::index[1]/@entry)">
instead of
<xsl:if test="not(@entry = preceding::index/@entry)">
In the first case you perform a single comparison using the fact that
the template was applied on a set of "index" elements already sorted by
the value of their @entry attribute.
The second test is more general, will work on an unsorted node-list,
but will require an average of count(//index) div 2 comparisons.
Cheers,
Dimitre Novatchev.
Paul Terray <terray@4dconcept.fr> wrote:
>- - One using the comparison with the preceding element in a sorted
subtree,
>with a sub-template. This give a solution like this :
>"Robert Stupak" <robert@stinklas.lt>
> <xsl:template match="text">
> <xsl:apply-templates select="index">
> <xsl:sort select="@entry"/>
> </xsl:apply-templates>
> </xsl:template>
>
>
> <xsl:template match="index">
> <xsl:if test="not(@entry = preceding::index/@entry)">
> <xsl:value-of select="@entry"/>
> </xsl:if>
> </xsl:template>
>
>This solution is clean to read, although I do prefer the other one for
>compacity and probably performance.
__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list