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

Subject: Re: [xsl] Remove a number at the beginning of some text
From: "Graeme Kidd" <coolkidd3@xxxxxxxxxxx>
Date: Wed, 7 Jan 2009 21:39:03 -0000
Hi Wendell,

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

Yes I can use XSLT 2.0 as I am using AltovaXML.exe


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.

No just <p>1.4 Heading</p>


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?

I searched 8 files and none of them had a space before the number i.e. <p> 1.2 Heading</p> but they all had at least one space after the number except for a few anomalies that had more than one.


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"?
Yes any number from 0-9 with periods e.g. 3.2.1 or 10.1.1

Does that give you a clearer picture of the problem?

Thanks so far,
Graeme

--------------------------------------------------
From: "Wendell Piez" <wapiez@xxxxxxxxxxxxxxxx>
Sent: Wednesday, January 07, 2009 7:48 PM
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [xsl] Remove a number at the beginning of some text

Graeme,

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).

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
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
======================================================================

Current Thread