[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Newbie needs help with sorting a filtered list

Subject: RE: Newbie needs help with sorting a filtered list
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 29 Jan 2007 09:18:29 -0000
RE:  Newbie needs help with sorting a filtered list
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.