Results 1 to 3 of 3

Thread: XSLT: If/else Question **SOLVED**

  1. #1

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476

    Question XSLT: If/else Question **SOLVED**

    Hey all, I have a small question concerning XSLT!

    Lets say I have a xml Document with this structure:

    <result>
    <id>1234</id>
    <test>0</id>
    </result>

    Now, what I want to do in my XSLT is to read the value of test. If that value is 0 or null, perfom some xslt else perform some different xslt.

    I know how to do a choose to see if an element is there but I dont know how to get the value:

    Heres what I have upt till now:

    <xsl:choose>
    <xsl:when test="test">
    // do something
    </xsl:when>
    </xsl:choose>
    <xsl: otherwise>
    // do something different
    </xsl: otherwise>

    Thanx in advance,

    Stephan
    Last edited by Sgt-Peppa; Aug 27th, 2003 at 10:37 AM.
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    I knew I had something:
    Code:
      <xsl:template match="test">
        <xsl:choose>
          <xsl:when test="0">
            <!-- Do your 0 XSL here -->
          </xsl:when>
          <xsl:when test<>"0">
            <!-- Do your other XSL here -->
          </xsl:when>
        </xsl:choose>
      </xsl:template>
    I think that will work...
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    SWEET! Thanks, it works!
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width