This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
substrings and identical numbers
- To: XSL-List at lists dot mulberrytech dot com
- Subject: [xsl] substrings and identical numbers
- From: tobi02 <tobiasreif at pinkjuice dot com>
- Date: Wed, 09 May 2001 18:04:25 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi...
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<!-- I need to get the first three places. They can be of any length.
Why does only the second one work like expected?
The first one doesn't work if the two numbers are the same.
(uncomment one then the other)
-->
<!-- XXXXXXXXXXXXXXXXXX first option XXXXXXXXXXXXXXXXXXXX -->
<!-- doesn't work with "a_a_20_20", "a_a_70_70" ....
gives "a_a_" without a number
works only with different numbers: "a_a_20_70"
-->
<!--
<xsl:variable name="input" select="'a_a_7000_7000'"/>
<xsl:variable name="output"
select="substring-before($input,substring-after(substring-after(substring-after($input,'_'),'_'),'_'))"/>
input: <xsl:value-of select="$input"/>
output: <xsl:value-of select="$output"/>
-->
<!-- XXXXXXXXXXXXXXXXXX second option XXXXXXXXXXXXXXXXXXXX -->
<!-- works correctly.
with "a_a_20_20", "a_a_70_70" .... also with different numbers like
"a_a_7000_9"
gives "a_a_7000_" with a number
-->
<!--
<xsl:variable name="input" select="'a_a_7000_7000'"/>
<xsl:variable name="pic_dir" select="'/images'"/>
<xsl:variable name="place1" select="substring-before($input,'_')"/>
<xsl:variable name="place2"
select="substring-before(substring-after($input,'_'),'_')"/>
<xsl:variable name="place3"
select="substring-before(substring-after(substring-after($input,'_'),'_'),'_')"/>
input: <xsl:value-of select="$input"/>
output: <xsl:value-of select="concat($place1, '_', $place2, '_',
$place3, '_')"/>
-->
</xsl:template>
</xsl:transform>
Tobi
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list