0

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"/>&#160;
            </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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.