I have something like the following XML: (but with more products)
<?xml version="1.0" encoding="UTF-8"?>
<products>
<product>
<name>Mango</name>
<type>fruit</type>
<imageurl>pic.jpeg</imageurl>
</product>
<product>
<name>banana</name>
<type>fruit</type>
<imageurl>pic3.jpeg</imageurl>
</product>
<product>
<name>duck</name>
<type>mammal</type>
<imageurl>pic2.jpeg</imageurl>
</product>
</products>
And this XSL: (but with more elements and attributes)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="typeSelected"/>
<xsl:template match="product/{$typeSelected}">
<xsl:element name="img">
<xsl:attribute name="class">juice</xsl:attribute>
<xsl:attribute name="src">
<xsl:value-of select="imageurl"/>
</xsl:attribute>
</xsl:element>
</div>
</xsl:template>
I'm setting the parameter's value with an external JavaScript file but I want to then group only the products who's <type> match the value of that parameter. Obviously the XSL needs changing and having read around I know I can't use parameters in a match statement. It feels like what I attempting shouldn't be too hard. Am I missing something obvious?
Given the parameter fruit I would like the output to be something like:
<img class="juice" src="pic.jpeg"/>
<img class="juice" src="pic3.jpeg"/>