Re: [xsl] Remove a number at the beginning of some text

Subject: Re: [xsl] Remove a number at the beginning of some text
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 07 Jan 2009 14:48:02 -0500

At 10:18 AM 1/7/2009, you wrote:
I wanting to remove a number in some text e.g.

< root>
< p>1.3 Heading < / p>
< root>

Should be:

< root>
< p>Heading < / p>
< root>

This is easier in XSLT 2.0, which supports regular expressions.

But solutions are possible even in 1.0.

A question: will the number ever be inside markup, as in <p><i>1.4</i> Heading</p> or <p><i>1.4 Heading</i></p>? If so, it's trickier.

More questions: does whitespace need to be preserved? will whitespace after the number ever be more than (other than) a single space? Will there ever be whitespace before the number?

Another question: is it fair to define a "number" for these purposes a string of characters that includes only the Arabic numerals 0-9 and periods? What about "1.0.1": is that a number? What about "1,000,000"? "MMIX"?

In any case, the problem is solvable but this is the sort of thing one needs to know (especially whether you can use XSLT 2.0).


Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
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

Current Thread