11.5 Precise Formatting 271
<xsl:value-of select="BindingStrength[1]"/>
but this should only be used in simple cases like this one. Do not expect such
abbreviations to work for more complicated expressions.
Summary
- Conditionals are used for special cases.
•Thexsl:ifconditional element is used to restrict to a single special case.
•Thexsl:chooseconditional element is used for handling several special
cases.
- Conditional can be specified inmatchandselectattributes by writing
the condition in brackets after the match criterion.
11.5 Precise Formatting
XSLT is not limited to producing only XML files. The output file can have any
format, although XSLT is primarily intended for XML. Of course, the input
document must necessarily be an XML document. This book, for example,
was written in XML and then translated to the LaTeX typesetting language
using XSLT.
The most common formatting issue is the formatting of numbers. The
format-numberfunction is used for formatting numbers. For example,
<xsl:value-of
select="format-number(3674.9806, ’#,##0.0##’)"/>
will print3,674.981.The#symbol represents a digit that will be omitted
if it is insignificant. Zero represents a digit (not just 0 ) that will always be
printed even if it is insignificant. As another example,
<xsl:value-of
select="format-number(3674.9805, ’#,##0.000’)"/>
will print3,674.980.
When XSLT is producing an XML file, it attempts to place the elements so
that one can read the output document without using any special tools. In
particular, the elements are successively indented to show the boundaries of