Subject: [xsl] Re: using format-number() for aligned text output From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 28 Mar 2001 10:11:53 -0500 |
Is it possible to define the Alignment of a Text/Number in XSLT ?
T:\ftemp>type eric.xml <items> <item> <name>Pen</name> <price>1.25</price> </item> <item> <name>Pencil</name> <price>0.5</price> </item> <item> <name>Bag</name> <price>12.38</price> </item> </items> T:\ftemp>type eric.xsl <?xml version="1.0"?><!--filename.xsl--> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:variable name="pad" select="' '"/> <xsl:variable name="pad-len" select="string-length($pad)"/>
<xsl:template match="/"> <xsl:for-each select="//item"> <xsl:value-of select="name"/> <xsl:value-of select="substring($pad,1,$pad-len - string-length(name))"/> <xsl:text>|</xsl:text> <xsl:value-of select="format-number(price,'####0.00')"/> <xsl:text> </xsl:text> </xsl:for-each> </xsl:template>
T:\ftemp>xt eric.xml eric.xsl <?xml version="1.0" encoding="utf-8"?> Pen |1.25 Pencil |0.50 Bag |12.38
-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML/OmniMark services, training, products. Book: Practical Transformation Using XSLT and XPath ISBN 1-894049-06-3 Article: What is XSLT? http://www.xml.com/pub/2000/08/holman/index.html Next public instructor-led training: 2001-04-06,2001-05-01,2001-05-14, - 2001-05-15,2001-05-16,2001-05-17,2001-05-21,2001-05-22, - 2001-06-18,2001-06-21,2001-07-20,2001-07-21,2001-09-19
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE: fixed width output (was u, Michael Kay | Thread | Re: [xsl] Re: using format-number(), Jeni Tennison |
RE: [xsl] Embedding HTML in XML?, Michael Kay | Date | Re: [xsl] CJK UTF-16 test, David Carlisle |
Month |