Re: [xsl] substrings and identical numbers

Subject: Re: [xsl] substrings and identical numbers
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Wed, 9 May 2001 09:41:01 -0700 (PDT)

Your problem is no different that parsing comma or semicolon 
seperated values.

Here is my general advice:

If you have to parse a limited number of known elements (and you
don't have any escaping of characters) you can use the following

<xsl:variable name="item1" select="substring-before($string,$seperator)"/>
<xsl:variable name="rest1" select="substring-after($string,$seperator)"/>

<xsl:variable name="item2" select="substring-before($rest1,$seperator)"/>
<xsl:variable name="rest2" select="substring-after($rest1,$seperator)"/>

<xsl:variable name="item3" select="substring-before($rest2,$seperator)"/>
<xsl:variable name="rest3" select="substring-after($rest2,$seperator)"/>

If you have to parse a variable number of elements or if you have
any type of escaping of characters, you need to write an custom
iterative solution.

If you need any type of random access to the i'th token in your string,
or if you will do anything more than make one pass on the data, you
are better off preprocessing you  XML to retag your string:


Hope that helps. Regards,


Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices

 XSL-List info and archive:

Current Thread