[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
> 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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|