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

Re: How to implement common functionality

Subject: Re: How to implement common functionality
From: "cutlass" <cutlass@xxxxxxxxxxx>
Date: Thu, 26 Jul 2001 14:52:10 +0100
common functionality
the first simplest step is to create a named template

this is how u would call the function;

<xsl:call-template name="converttodecimal">
   <xsl:with-param name="amount" select="@DOLLARAMT" />
</xsl:call-template>

here is the named template you are calling;

<xsl:template name="converttodecimal">
 <xsl:param name="amount" select="''" />
<xsl:value-of
select="format-number((number(substring($amount,2)))div 100, '00.00')"/>
</xsl:template>

CSS file is for presentation details only, though i am not an expert.

here is something more complex ( taken from
http://www.exslt.org/str/functions/align/index.html ), note the str: prefix,
to use this particular example you will have to declare a namespace str: i
would suggest taking a look at the above exslt link,

<xsl:call-template name="str:align">
   <xsl:with-param name="string" select="string" />
   <xsl:with-param name="padding" select="string" />
   <xsl:with-param name="alignment" select="string" />?
</xsl:call-template>


<xsl:template name="str:align">
  <xsl:param name="string" select="''" />
  <xsl:param name="padding" select="''" />
  <xsl:param name="alignment" select="'left'" />
  <xsl:variable name="str-length" select="string-length($string)" />
  <xsl:variable name="pad-length" select="string-length($padding)" />
<xsl:choose>
<xsl:when test="$str-length >= $pad-length">
  <xsl:value-of select="substring($string, 1, $pad-length)" />
  </xsl:when>
<xsl:when test="$alignment = 'center'">
  <xsl:variable name="half-remainder" select="floor(($pad-length -
$str-length) div 2)" />
  <xsl:value-of select="substring($padding, 1, $half-remainder)" />
  <xsl:value-of select="$string" />
  <xsl:value-of select="substring($padding, $str-length + $half-remainder +
1)" />
  </xsl:when>
<xsl:when test="$alignment = 'right'">
  <xsl:value-of select="substring($padding, 1, $pad-length - $str-length)"
/>
  <xsl:value-of select="$string" />
  </xsl:when>
<xsl:otherwise>
 <xsl:value-of select="$string" />
  <xsl:value-of select="substring($padding, $str-length + 1)" />
  </xsl:otherwise>
  </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

once u have mastered this u will may want to bind these functions to
specific namespaces, etc, anyway this is a good first step


cheers, jim fuller


----- Original Message -----
From: "Haque, Suraiya" <Suraiya.Haque@xxxxxxx>
To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, July 26, 2001 2:35 PM
Subject:  How to implement common functionality


> I have to do some text formatting in multiple XSL files using the
> same format. I would like to define this once in a central file and reuse
it
> in the XSL files. Right now I have the formatting implemented for each
> field.
>
> In my XML, 10.00 is specified as +000000001000
> and I format it to 10.00 by using
>
> <xsl:value-of
> select="format-number((number(substring(@DOLLARAMT,2)))div 100,
'00.00')"/>
>
> I would like to define the formatting command in a central place so
> that I can do something like this:
>
> <xsl:value-of select="convertToDecimal(@DOLLARAMT)"/>
>
> Is there a way to do this? Can I do this in a css file?
>
> Thanks,
> Suraiya
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.