Assigning value to variable based on xsl:choose test

Discussion in 'XML' started by michael75, Aug 3, 2010.

  1. michael75

    michael75

    Joined:
    Aug 3, 2010
    Messages:
    1
    Hello,

    can somebody tell me why this code does not work?

    Code:
    <xsl:variable name="pagesvar">
        <xsl:choose>
            <xsl:when test="/p/divi/text() = 'bla'">
                <xsl:value-of select="/p/navigation/page//page[template='T1']"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="/p/navigation/page//page[template='T2']"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>
    
    I know that following code works, but in the future I will have more test cases, so its just a temporary solution.
    Code:
    <xsl:variable name="pagesvar" select="if (/p/divi/text()='bla') then /p/navigation/page//page[template='T1'] else /p/navigation/page//page[template='T2']"/>
    
    thanks,
    michael
    michael75, Aug 3, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ruthless

    xsl:choose

    Ruthless, Dec 26, 2003, in forum: XML
    Replies:
    2
    Views:
    448
    Ruthless
    Dec 27, 2003
  2. schaf@2wire.ch
    Replies:
    1
    Views:
    3,571
    A. Bolmarcich
    May 27, 2005
  3. freefly_xml
    Replies:
    4
    Views:
    831
    freefly_xml
    May 16, 2006
  4. mark4asp
    Replies:
    4
    Views:
    442
    mark4asp
    Dec 21, 2007
  5. weston
    Replies:
    1
    Views:
    234
    Richard Cornford
    Sep 22, 2006
Loading...

Share This Page