xsl-list
[Top] [All Lists]

RE: [xsl] Expanding Tabs

2010-03-29 16:08:36
Hi,

At 04:34 PM 3/29/2010, Charles wrote:
The XSLT function you are looking for is "translate()". The concept is more general than what you are used to thinking about, so it's not surprising that by looking for a narrower concept (i.e., "expand"), that you haven't been able to find it.

Well yes ... "expand" is either narrower or broader, depending on what you mean by "expand". It's not a term likely to get you much precision in a search.

Another aspect of this problem that explains why this might be hard to find is that XSLT wasn't actually designed with string processing in mind. There's the translate() function, which can be used to convert single tabs into single spaces, and there are various methods designed to work in XSLT 1.0 (most of them necessarily heavy-duty for such a "simple" requirement), and there are straightforward regular-expression capabilities in XPath/XSLT 2.0. So it's not as if this can't or hasn't been done.

It's more that the precise approach isn't as obvious as one might think. Convert tab characters into "the appropriate number of blanks" -- what's the appropriate number? Is it fixed by the stylesheet? Must it be parameterized? Are tabs everywhere to be converted, or only at the start of lines? Can this use XSLT 2.0 or must it be XSLT 1.0? Etc. etc.

How about replace(.,'	','    ') ?

Cheers,
Wendell



======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)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
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>