xsl:decimal-format

only for RuBoard

xsl:decimal-format

The xsl:decimal-format element declares a decimal-format, which controls the interpretation of a format pattern used by the format-number function. If there is a name attribute, then the element declares a named decimal-format; otherwise , it declares the default decimal-format.

Attributes

Attribute Name

Enforced

Description

Values

Name

Optional

The name of the decimal format.

QName

decimal-separator

Optional

The character used for a decimal sign. The default is a period ( . ).

Character

grouping-separator

Optional

The character used as a grouping (for example, thousands) separator. The default is a comma ( , ).

Character

infinity

Optional

The string used to represent infinity. The default is the string Infinity .

String

minus-sign

Optional

The character used as the default minus sign. The default is the hyphen-minus character ( -, #x2D ).

Character

NaN

Optional

The string used to represent the NaN value. The default is the string NaN .

String

percent

Optional

The character used as a percent sign. The default is the percent character ( % ).

Character

per-mile

Optional

The character used as a per mille sign. The default is the Unicode per-mille character ( #x2030 ).

Character

zero-digit

Optional

The character used as a digit zero. The default is the digit zero ( ).

Character

digit

Optional

The character used for a digit in the format pattern. The default is the pound sign ( # ).

Character

pattern-separator

Optional

The character used to separate positive and negative subpatterns in a pattern. The default value is the semicolon character (;).

Character

Example

The following example relies on the fact that division by 0 for a non-zero number yields Infinity , while division of 0 by 0 yields NaN (Not a Number). We change the output of the value displayed for both NaN and Infinity values by declaring a default decimal format.

 <?xml version="1.0" encoding="UTF-8" ?>  <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">       <xsl:decimal-format infinity="An infinite number" NaN="Not a number" digit="9" />       <xsl:template match="/">              <!--Infinity-->            <xsl:value-of select="format-number(1 div 0,'999,9999.99')" />            <br />            <!--NaN-->            <xsl:value-of select="format-number(0 div 0,'999,9999.99')" />       </xsl:template>  </xsl:stylesheet> 

This results in the following output:

 <?xml version="1.0" encoding="UTF-16"?>An infinite number<br />Not a number 

Parent Elements

xsl:stylesheet or xsl:tranform.

Child Elements

None.

only for RuBoard


XML and ASP. NET
XML and ASP.NET
ISBN: B000H2MXOM
EAN: N/A
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net