|
Subject: RE: [xsl] Newbie needs help with sorting a filtered list From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 29 Jan 2007 09:18:29 -0000 |
> This gives me the correct items, but not in alphabetical order:
>
> <xsl:param name="param1"/>
> <xsl:param name="param2"/>
>
> <xsl:template match="catalog/entry">
> <xsl:if test="category[@type=$param1] and
> category[@subcat=$param2]">
> <xsl:for-each select="word">
> <xsl:sort/>
> <xsl:apply-templates/><br/>
> </xsl:for-each>
> </xsl:if>
> </xsl:template>
>
Each entry only contains one word, so there's not much point sorting the
words within an entry.
>
> This one gives me an alphabetized list, but of all the items,
> not just the ones that match the params:
>
> <xsl:template match="catalog">
> <xsl:if test="entry/category[@type=$param1] and
> entry/category[@subcat=$param2]">
> <xsl:for-each select="entry/word">
> <xsl:sort/>
> <xsl:apply-templates/><br/>
> </xsl:for-each>
> </xsl:if>
> </xsl:template>
>
That's because you're first testing if a qualifying entry exists, and if it
does, you're processing all the entries whether they qualify or not.
You want:
<xsl:template match="catalog">
<xsl:for-each select="entry[category[@type=$param1 and
@subcat=$param2]]/word">
<xsl:sort/>
<xsl:apply-templates/><br/>
</xsl:for-each>
</xsl:template>
Michael Kay
http://www.saxonica.com/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Newbie needs help with so, James A. Robinson | Thread | Re: [xsl] Newbie needs help with so, G. Ken Holman |
| Re: [xsl] xinclude in xslt 2.0 now , Colin Paul Adams | Date | [xsl] IDE, Antony Quinn |
| Month |