Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT Variables and Choose/Otherwise not working right
    primarykey
    data
    text
    <p>I have some XSLT that looks like:</p> <pre><code>&lt;xsl:choose&gt; &lt;xsl:when test="string(//User[@UserID = $UserID]/ROOT/Prop[@Nm = 'GreaseBoardCategory'])"&gt; &lt;xsl:variable name="Type" select="concat('Documenter', //User[@UserID = $UserID]/ROOT/Prop[@Nm = 'GreaseBoardCategory'])"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:variable name="Type" select="concat('Documenter', user:GetUserType(string(//Payload/@SiteID), string(@UserID)))"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; </code></pre> <p>And I want to assign a variable to it called "Type" I see from other examples that I should be doing this instead:</p> <pre><code>&lt;xsl:variable name="Type"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="string(//User[@UserID = $UserID]/ROOT/Prop[@Nm = 'GreaseBoardCategory'])"&gt; &lt;xsl:value-of select="concat('Documenter', //User[@UserID = $UserID]/ROOT/Prop[@Nm = 'GreaseBoardCategory'])"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="concat('Documenter', user:GetUserType(string(//Payload/@SiteID), string(@UserID)))"/&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:variable&gt; </code></pre> <p>But my variable is NOT getting set. It should hit the Otherwise block but never does. Any ideas? It doesn't get set to anything..</p> <p>The only way to get Type to be set is to do away with the Choose/When/Otherwise statements and just pick one of the two options, like:</p> <pre><code>&lt;xsl:variable name="Type" select="concat('Documenter', //User[@UserID = $UserID]/ROOT/Prop[@Nm = 'GreaseBoardCategory'])"/&gt; </code></pre> <p>for example.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload