(XSLT 1.0.) Given a variable called Rows which contains the following (example):
Input
<AllResults>
<Result>
<subject>can be filtered by filter 1</subject>
<type>can be filtered by filter 2</type>
<date>can be filtered by filter 3</date>
</Result>
<Result> ...
</Result>
</AllResults>
I have 3 filter variables. For each filter, I'd like to apply the filter to the input shown above if the filter variable is not empty. I'd like to store the filtered result, the items that match the filters, into a new variable. I tried the following, but I got an error message about it (filterResult) being a "result tree instead of a node-set". The Rows variable is a node-set, as I have determined by using a debugger.
Part of the XSL
<xsl:variable name="filterResult">
<xsl:choose>
<xsl:when test="$filter1 != '' and $filter2 != '' and $filter3 != ''">
<xsl:copy-of select="$Rows[date=$filter1 and type=$filter2 and subject=$filter3]" />
</xsl:when>
<xsl:when test="$filter1 != '' and $filter2 != ''">
<xsl:copy-of select="$Rows[date=$filter1 and type=$filter2]" />
</xsl:when>
<xsl:when test="$filter1 != '' and $filter3 != ''">
<xsl:copy-of select="$Rows[date=$filter1 and subject=$filter3]" />
</xsl:when>
<xsl:when test="$filter3 != '' and $filter2 != ''">
<xsl:copy-of select="$Rows[type=$filter2 and subject=$filter3]" />
</xsl:when>
<xsl:when test="$filter1 != ''">
<xsl:copy-of select="$Rows[date=$filter1]" />
</xsl:when>
<xsl:when test="$filter3 != ''">
<xsl:copy-of select="$Rows[subject=$filter3]" />
</xsl:when>
<xsl:when test="$filter2 != ''">
<xsl:copy-of select="$Rows[type=$filter2]" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$Rows" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
I realize that copy-of produces a result tree and not a node-set, but I am not sure HOW to produce a node set given my 3 filters requirement that I described above.
Additional Info
I do know that I could do something like <xsl:variable name="me" select="/set/node"/>
which would create a variable containing a node set but I don't see how that helps me, since I have a lot of possible conditions (given the three filters).