Subject: Re: [xsl] String Manipulation in XSL From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 26 Oct 2001 12:43:53 -0400 |
I was wondering if anyone had a solution for this problem. I get an element through which has a string which can be variable length. It could be 20 characters long, 40, 60, upto anything really.
I'm wanting to put in a space every 20 characters, and am unsure on how to do this.
T:\ftemp>type peter.xml <?xml version="1.0" encoding="utf-8"?> <value>12345678901234567890123456789012345678901234567</value> T:\ftemp>type peter.xsl <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/"> <xsl:call-template name="do-a-string"> <xsl:with-param name="string" select="/value"/> </xsl:call-template> </xsl:template>
<xsl:template name="do-a-string"> <xsl:param name="string"/> <xsl:if test="$string"> <xsl:value-of select="substring($string,1,20)"/> <xsl:text> </xsl:text> <xsl:call-template name="do-a-string"> <xsl:with-param name="string" select="substring($string,21)"/> </xsl:call-template> </xsl:if> </xsl:template>
-- 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 training (instructor-live, Internet-live, and web-based): -2001-10-22,11-01,11-02,11-05,11-19,11-21,12-03,12-05,12-09,12-10,12-19
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] String Manipulation in XSL, Peter . FLYNN | Thread | Re: [xsl] String Manipulation in XS, David Carlisle |
RE: [xsl] escaping from CDATA, Chris Bayes | Date | Re: [xsl] escaping from CDATA, David Carlisle |
Month |