It's been a while since I've done any XSL, so forgive me if this is a little confusing.
I have an XML file, which I need to transform with XSL. It all works well until I try and detect "category", because there are multiple "category" nodes for each item.
Part of XML file:
<ROOT>
<blog day="20" id="4" live="201007200947" month="7" monthname="July" year="2010">
<blog_date><![CDATA[2010-07-20 09:47:00.0]]></blog_date>
<filepath><![CDATA[2010/20100720_4.htm]]></filepath>
<title><![CDATA[Blog title 1]]></title>
<category><![CDATA[Testing]]></category>
<category><![CDATA[Training]]></category>
<author_id><![CDATA[146]]></author_id>
<keywords/>
<summary><![CDATA[New British Gas Smart Metering recruits Paul Williams and Alex Egan give their first impressions.]]></summary>
</blog>
Sample of XSL file
<xsl:template match="//ROOT">
<xsl:apply-templates select="//blog
[@live <= $ThisDate]
[not($AuthorId) or (author_id = $AuthorId)]
[not($BlogYear) or (not($BlogMonth) or (@month = $BlogMonth and @year = $BlogYear))]
[not($BlogCategory) or (translate(translate(category, $uppercase, $lowercase),$specialchar,'') = $BlogCategory)]
">
<xsl:sort value="blog_date" order="descending"/>
</xsl:apply-templates>
$BlogCategory is sent in a url, and has all special characters and spaces stripped out (hence the "translate" on "category").
If I filter the XML by category "Testing" then it works fine, but if I sort by category "Training" it returns no values. I know this is because it's only looking at the first node with the name "category", but can anyone suggest a fix?
I've tried a for-each loop in the past, and it works but is not ideal because the position() always equals 1, so adding page navigation within the xsl file is not possible.
Ideally I would like a fix that could stay within the apply-template.
I'm using XSLT 2.0.
Thanks, Kate