xsl-list
[Top] [All Lists]

RE: parsing version number strings

2004-10-20 06:40:13
In pure XSLT 1.0 this needs a recursive template that reads one piece of the
string at a time using substring-before - it's a textbook example of using
recursion.

In 2.0 there's a tokenize() function which makes it much easier. You can
also find str:tokenize() as an EXSLT extension for many 1.0 processors.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Ed_Owen(_at_)PlayStation(_dot_)Sony(_dot_)com 
[mailto:Ed_Owen(_at_)PlayStation(_dot_)Sony(_dot_)com] 
Sent: 20 October 2004 01:00
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] parsing version number strings





Has anyone out there come up with a method to parse an 
arbitrary version
number string in an XSLT for numeric comparison?

For example, I'm parsing some Doxygen output and I need to 
apply different
templates based on which version of Doxygen produced the output. For
example, I have something that needs to be applied only to 
versions 1.3.4
and older.

The version of Doxygen is stored in an attribute of the root <doxygen>
element: <doxygen version="1.3.4">

Here is a sequence of increasingly newer version numbers that 
illustrates
some of the complexities of parsing this string:

1.2.9
1.2.10
1.2.10.1
1.3
1.3.1
1.3.2
1.3.2.1

There doesn't seem to be an XPath function that gives me the 
position of a
character within a string, which kind of hamstrings me, as 
far as I can
tell.

Anyone solved this problem before?

thanks
Ed

Ed Owen
Project Manager
Information Design and Development (IDD)
Sony Computer Entertainment America
e-mail: ed_owen(_at_)playstation(_dot_)sony(_dot_)com



--+------------------------------------------------------------------
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>