This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: substrings and identical numbers


>a_a_20_20

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
approach:

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

<info>
 <item1>a</item1>
 <item2>a</item2> 
 <item3>20</item3>
 <item4>20</item4>
</info>

Hope that helps. Regards,

Dan

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]