|
Subject: Re: [xsl] String comparison From: pankaj.c@xxxxxxxxxxxxxxxxxx Date: Fri, 24 Sep 2010 14:31:40 +0530 |
Modified version compares upto 6 digits/characters. BUT I STILL BELIEVE
there must be better way:
<xsl:template match="pages">
<xsl:copy>
<xsl:apply-templates select="./first-page"/>
<xsl:choose>
<xsl:when test="./last-page">
<xsl:text>—</xsl:text>
<xsl:apply-templates select="./last-page"/>
</xsl:when>
</xsl:choose>
</xsl:copy>
</xsl:template>
<xsl:template match="last-page">
<xsl:copy>
<xsl:choose>
<xsl:when
test="not(string-length(.)=string-length(preceding-sibling::first-page))
or string-length(.)=1">
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="string(.)=string(preceding-sibling::first-page)">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="not(substring(.,2,1) =
substring(preceding-sibling::first-page,2,1))">
<xsl:value-of
select="substring(.,2,string-length(.))"/>
</xsl:when>
<xsl:when test="not(substring(.,3,1) =
substring(preceding-sibling::first-page,3,1))">
<xsl:value-of
select="substring(.,3,string-length(.))"/>
</xsl:when>
<xsl:when test="not(substring(.,4,1) =
substring(preceding-sibling::first-page,4,1))">
<xsl:value-of
select="substring(.,4,string-length(.))"/>
</xsl:when>
<xsl:when test="not(substring(.,5,1) =
substring(preceding-sibling::first-page,5,1))">
<xsl:value-of
select="substring(.,5,string-length(.))"/>
</xsl:when>
<xsl:when test="not(substring(.,6,1) =
substring(preceding-sibling::first-page,6,1))">
<xsl:value-of
select="substring(.,6,string-length(.))"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
Ooooooooops, this seems to be not correct as it gives incorrect output for
few cases.
Thanks for reading anyway....... getting this done again.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] String comparison, pankaj . c | Thread | Re: [xsl] String comparison, Wolfgang Laun |
| Re: [xsl] Question about grouping, Michael Kay | Date | Re: [xsl] String comparison, Michael Kay |
| Month |