Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: xsl:choose

  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    xsl:choose

    I'm trying to change the color of the text content within a .xml file through my .xslt file; change it so it displays in red. Text content is within a <brandName registered="Bayer"> & other in <brandName registered="McNeil"> , same .xml file. Aside from the color i would also like to display the "()" around the company name.

    I was trying something but it fails.. Never used it before so I'm probably using it the wrong way.

    This is what I have for the colour change, and addition of brackets around company name within the .xslt:
    Code:
          <xsl:choose>
            <xsl:when test="@registered='Aspirin'">
              <font color="red">
                <xsl:value-of select="@registered='(Bayer)'"/>
              </font>
            </xsl:when>
            <xsl:when test="@registered='Tylenol'">
              <font color="red">
                <xsl:value-of select="@registered='(McNeil)'"/>
              </font>
            </xsl:when>
            <xsl:otherwise>
              <font style="bold">
                <xsl:value-of select="@registered"/>
              </font>
            </xsl:otherwise>
          </xsl:choose>
    Any help is greatly appreciated.
    Last edited by Alex Vincent; 09-24-2008 at 09:33 PM. Reason: switching to code tags to disable smileys

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by Kusko View Post
    Code:
          <xsl:choose>
            <xsl:when test="@registered='Aspirin'">
              <font color="red">
                <xsl:value-of select="@registered='(Bayer)'"/>
              </font>
            </xsl:when>
            <xsl:when test="@registered='Tylenol'">
              <font color="red">
                <xsl:value-of select="@registered='(McNeil)'"/>
              </font>
            </xsl:when>
            <xsl:otherwise>
              <font style="bold">
                <xsl:value-of select="@registered"/>
              </font>
            </xsl:otherwise>
          </xsl:choose>
    what do you expect to get by giving a boolean condition for a value-of?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

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