OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] trying to use abs()

[ Lists Home | Date Index | Thread Index ]

As Michael pointed out, please post XSLT related questions at the
xsl-list hosted by www.mulberrytech.com.

To answer your present question, I would like to suggest a simple way
to implement abs() functionality in XSLT 1.0 (XSLT 2.0 has it
built-in, so no need to worry with XSLT 2.0).

Write a named template for this..

Here is the code:

<xsl:template name="abs">
   <xsl:param name="n" />

      <xsl:when test="$n &gt;= 0">
        <xsl:value-of select="$n" />
        <xsl:value-of select="0 - $n" />

Call this as:

<xsl:call-template name="abs">
    <xsl:with-param name="n" select="3" />

Will produce output: 3

<xsl:call-template name="abs">
   <xsl:with-param name="n" select="-10" />

Will produce output: 10


On 7/6/06, Webmaster <Webmaster@comtrol.com> wrote:
> Hello. I'm using Saxon 6.5.3 and am trying to get the abs function to work.
> I tried math: and fn: but I'm getting the error: "unknown system function".
> I've tried several name spaces, with out any success.
> It seems to me that maybe saxon doesn't with it? my xsl namespace is:
> http://www.w3.org/1999/XSL/Transform
> At this point I'm kinda lost and not really knowing what I need. So how do I
> find a libary of math functions? do I have to download some files? do I have
> to update the xsl namespace?
> Thanks!
> LN


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS