Here is a related answer to a similar issue:
https://stackoverflow.com/a/19140663/2287576
Variable definition 1:
<xsl:variable name="duty-assignments"
select="$DutyHistory/msa:DutyAssignmentHistory/msa:DutyAssignments/msa:DutyAssignmentEntry[@Week=$Week and @Mode='Midweek']/msa:Assignment"/>
Variable definition 2:
<xsl:variable name="duty-assignments"
select="$DutyHistory/msa:DutyAssignmentHistory/msa:DutyAssignments/msa:DutyAssignmentEntry[@Week=$Week and @Mode='Weekly']/msa:Assignment"/>
I can use either of these definitions and my script behaves. But, if I apply the logic of the linked answer:
<xsl:variable name="duty-assignments">
<xsl:choose>
<xsl:when test="CircuitVisit='1'>
<xsl:value-of select="$DutyHistory/msa:DutyAssignmentHistory/msa:DutyAssignments/msa:DutyAssignmentEntry[@Week=$Week and @Mode='Weekly']/msa:Assignment"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$DutyHistory/msa:DutyAssignmentHistory/msa:DutyAssignments/msa:DutyAssignmentEntry[@Week=$Week and @Mode='Midweek']/msa:Assignment"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
My report stopped rendering. As mentioned it is OK if I drop using the choose statement and only assign one node-set to variable.
Is there some concepts I am overlooking for XSLT1 and this kind of activity?
Additional Information
Here is an extract of some duty assignments:
<?xml version="1.0" encoding="utf-8"?>
<DutyAssignmentHistory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.publictalksoftware.co.uk/msa">
<DutyAssignments>
<DutyAssignmentEntry Date="2023-09-21" Week="W20230918" Template="0" Mode="Midweek">
<Assignment Index="13" IndexType="Fixed">Name 1</Assignment>
<Assignment Index="14" IndexType="Fixed">Name 2</Assignment>
<Assignment Index="15" IndexType="Fixed">Name 3</Assignment>
<Assignment Index="7" IndexType="Fixed">Name 4</Assignment>
<Assignment Index="8" IndexType="Fixed">Name 5</Assignment>
<Assignment Index="5" IndexType="Fixed">Name 6</Assignment>
<Assignment Index="17" IndexType="Fixed">Name 7</Assignment>
</DutyAssignmentEntry>
<DutyAssignmentEntry Date="2023-09-24" Week="W20230918" Template="0" Mode="Weekend">
<Assignment Index="13" IndexType="Fixed">Name 8</Assignment>
<Assignment Index="14" IndexType="Fixed">Name 9</Assignment>
<Assignment Index="15" IndexType="Fixed">Name 10</Assignment>
<Assignment Index="7" IndexType="Fixed">Name 11</Assignment>
<Assignment Index="8" IndexType="Fixed">Name 12</Assignment>
<Assignment Index="5" IndexType="Fixed">Name 13</Assignment>
<Assignment Index="17" IndexType="Fixed">Name 14</Assignment>
</DutyAssignmentEntry>
<DutyAssignmentEntry Date="2023-09-26" Week="W20230925" Template="0" Mode="Weekly">
<Assignment Index="13" IndexType="Fixed">Name 15</Assignment>
<Assignment Index="14" IndexType="Fixed">Name 1</Assignment>
<Assignment Index="15" IndexType="Fixed">Name 2</Assignment>
<Assignment Index="7" IndexType="Fixed">Name 3</Assignment>
<Assignment Index="8" IndexType="Fixed">Name 4</Assignment>
<Assignment Index="5" IndexType="Fixed">Name 5</Assignment>
<Assignment Index="17" IndexType="Fixed">Name 6</Assignment>
</DutyAssignmentEntry>
<DutyAssignmentEntry Date="2023-10-01" Week="W20230925" Template="0" Mode="Weekend">
<Assignment Index="13" IndexType="Fixed">Name 7</Assignment>
<Assignment Index="14" IndexType="Fixed">Name 8</Assignment>
<Assignment Index="15" IndexType="Fixed">Name 9</Assignment>
<Assignment Index="7" IndexType="Fixed">Name 10</Assignment>
<Assignment Index="8" IndexType="Fixed">Name 11</Assignment>
<Assignment Index="5" IndexType="Fixed">Name 12</Assignment>
<Assignment Index="17" IndexType="Fixed">Name 13</Assignment>
</DutyAssignmentEntry>
</DutyAssignments>
</DutyAssignmentHistory>
And, here is an example of how I want to use the variable data:
<xsl:value-of select="$duty-assignments[@Index='15' and @IndexType='Fixed']"/>
The function that defines and uses the variable is called like this:
<xsl:call-template name="DutyAssignments"/>
And the function itself:
<!-- Duty assignment template -->
<xsl:template name="DutyAssignments">
</xsl:template>