[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xsl not powerfull enough (was: re: xsl-sort)

Subject: xsl not powerfull enough (was: re: xsl-sort)
From: Goetz Bock <bock@xxxxxxxxxxx>
Date: Sat, 23 Dec 2000 17:45:18 +0100
xsl not
On Sat, Dec 23 '00 at 08:48, Jack A. Zucker wrote:
> Maybe I need to do more homework but it seems that xslt is not a very rich
> programming language for general-purpose stuff which is why I was previously
> using script to do certain things. For example, how do you output a number
> as a hex string in xsl(t) without resorting to indexing into an array of
> characters representing the hex digits?
The same way you do it with any other programmin language that does not
bring a function for this (how did you do it?):

<xsl:template name="printHex">
  <xsl:param name="number">0</xsl:param>

  <xsl:variable name="low">
    <xsl:value-of select="$number mod 16"/>
  </xsl:variable>

  <xsl:variable name="high">
    <xsl:value-of select="floor($number div 16)"/>
  </xsl:variable>

  <xsl:choose>
    <xsl:when test="$high &gt; 0">
      <xsl:call-template name="printHex">
        <xsl:with-param name="number">
          <xsl:value-of select="$high"/>
        </xsl:with-param>
      </xsl:call-template>  
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>0x</xsl:text>
    </xsl:otherwise>
  </xsl:choose>  

  <xsl:choose>
    <xsl:when test="$low &lt; 10">
      <xsl:value-of select="$low"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="temp">
        <xsl:value-of select="$low - 10"/>
      </xsl:variable>

      <xsl:value-of select="translate($temp, '012345', 'ABCDEF')"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>  

It XSL-T's div would have been a div and not a / this would have taken
about 5 min ...

    Goetz.

Attachment: pgp00003.pgp
Description: PGP signature

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.