Reputation: 19157
I have seen the answers here but they are not working.
I can use either of the following:
<xsl:variable name="AssignHistory" select="document('AssignHistory.xml')"/>
<xsl:variable name="AssignHistory" select="document('ForeignAssignHistory.xml')"/>
But I need to make this dynamic now. So I tried this but it doesn't like it:
<xsl:variable name="AssignHistory">
<xsl:choose>
<xsl:when test="//Settings/ForeignGroupMode=1">
<xsl:value-of select="document('ForeignAssignHistory.xml')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="document('AssignHistory.xml')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
It just won't work. It says:
Reference to variable or parameter 'AssignHistory' must evaluate to a node list.
To give this some context. This is what I have at the moment:
<td class="cellComments" colspan="4">
<xsl:variable name="AssignHistory" select="document('AssignHistory.xml')"/>
<xsl:variable name="week" select="Date/@NextWeek"/>
<xsl:variable name="NextReviewQuestion" select="$AssignHistory/AssignmentHistory/*[name()=$week]/ReviewQuestion"/>
<xsl:if test="normalize-space($NextReviewQuestion) != ''">
<xsl:if test="normalize-space(ReviewQuestion) != ''">
<span class="textReviewQuestionLabel">
<xsl:value-of select="//Labels/NextReviewQuestion"/> 
</span>
<span class="textReviewQuestion">
<xsl:value-of select="$NextReviewQuestion"/>
</span>
<br />
</xsl:if>
</xsl:if>
<br />
<br />
<br />
</td>
And I wanted to introduce that selection logic to choose the correct document.
Upvotes: 0
Views: 27
Reputation: 117073
Perhaps try something like:
<xsl:variable name="AssignHistoryPath">
<xsl:choose>
<xsl:when test="//Settings/ForeignGroupMode=1">ForeignAssignHistory.xml</xsl:when>
<xsl:otherwise>AssignHistory.xml</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="AssignHistory" select="document($AssignHistoryPath)"/>
Untested, because because no code to test with was provided.
Upvotes: 1