I have an XML document of store locations which have a Type node indicating the type of store and an existing set of templates for adding a key to each Location based on it's state which then adds these to an HTML in order of their state.
What I need to do is exclude all of the states from display that do not have a Type of 1. It's easy enough in the for-each loop to skip display of those Locations but I end up with states displaying that have no values in them.
Here's the code inside the <select/>
HTML tag:
<xsl:apply-templates select="$locations/descendant::Locations" mode="locations.list"/>
That template looks like this:
<xsl:template match="Locations" mode="locations.list">
<xsl:apply-templates select="Location[generate-id(.) = generate-id(key('state', State)[1])]" mode="locations.list.location"/>
</xsl:template>
The template it calls looks like:
<xsl:template match="Location" mode="locations.list.location">
<option value="state"><xsl:value-of select="normalize-space(State)"/></option>
<xsl:for-each select="key('state', State)">
<option value="{normalize-space(SiteKey)}"><xsl:value-of select="normalize-space(Location)/></option>
</xsl:for-each>
<option value=""/>
</xsl:template>
Ordinarily in the <xsl:apply-templates select="Location[generate-id(.) = generate-id(key('state', State)[1])]" mode="locations.list.location"/>
I'd just indicate in the select that I was only interested in Locations that have a Type of '1' but I can't seem to find a way to insert that condition along with the key generation code.