This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Fixed-length String Output
- To: xsl-list at mulberrytech dot com
- Subject: Re: Fixed-length String Output
- From: Wendell Piez <wapiez at mulberrytech dot com>
- Date: Wed, 04 Oct 2000 12:33:52 +0100
- Reply-To: xsl-list at mulberrytech dot com
Deirdre,
A very similar question came up just recently. You should check out XPath's
string-handling functions.
Something like
<xsl:value-of select="substring(concat($string, ' '), 1, 12))"/>
always gives you a string twelve characters long, either the first twelve
characters of $string, or $string padded out with spaces. Variables can be
also be useful to make things easier to read, reuse and maintain -- for
example
<xsl:variable name="spacex12" select="' '"/>
and then
<xsl:value-of select="substring(concat($string, $spacex12), 1, 12))"/>
Have fun,
Wendell
At 04:27 PM 10/4/00 +0100, you wrote:
>
>
>Hi,
>
>I am trying to transform an incoming XML message to a format that will be
>acceptable to our existing software package. However the existing package
>excepts data on a fixed-length basis. This is the way we wish to continue.
>
>I was wondering is there a way to force the output of select statement to
>take up a certain amount of space. Not all of the elements will be
>numbers. What I need is something like the format-number function but for
>strings. I taught maybe there might be an attribute in value-of that would
>do it, but there doesn't appear to be. Is there anything currently
>available in XSLT that would do this for me? I am using the Xalan
>processor.
>
>Thanks for the help I have received so far. I have ordered a copy of "XSLT
>Programmer's Reference". This hopefully will enable me to answer my own
>questions.
>
>Thanks again,
>Deirdre O'Brien
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list