Subject: RE: Fixed-length String Output From: "DuCharme, Robert" <Robert.DuCharme@xxxxxxxxxx> Date: Wed, 4 Oct 2000 14:36:14 -0400 |
>Something like ><xsl:value-of select="substring(concat($string, ' '), 1, 12))"/> Just as a challenge, I took it a little further. The following outputs the color values in this document <test> <color>red</color> <color>blue</color> <color>yellow</color> </test> at 12 characters each, right aligned: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:variable name="fieldWidth">12</xsl:variable> <xsl:template match="color"> <xsl:variable name="valueLength" select="string-length(normalize-space(.))"/> <xsl:variable name="padding" select="$fieldWidth - $valueLength"/> <xsl:text>[</xsl:text> <xsl:value-of select="substring(' ',1,$padding)"/> <xsl:value-of select="."/> <xsl:text>]</xsl:text> </xsl:template> </xsl:stylesheet> giving this output: <?xml version="1.0" encoding="utf-8"?> [ red] [ blue] [ yellow] I'm starting to like local variables more! Bob DuCharme www.snee.com/bob <bob@ snee.com> "The elements be kind to thee, and make thy spirits all of comfort!" Anthony and Cleopatra, III ii XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Fixed-length String Output, Kay Michael | Thread | RE: Fixed-length String Output, Nate Austin |
RE: HTML parameters and Ampersands, Kay Michael | Date | RE: XSLBench - XSLT Processor Bench, Kay Michael |
Month |