Dear All,
I am having the following inputs:
1. <cross-ref>[<cr refid="MEP_L_bib5">5</cr>-<cr
refid="MEP_L_bib7">7</cr>, <cr refid="MEP_L_bib21">21</cr>-<cr
refid="MEP_L_bib24">24</cr>]</cross-ref>
2. <cross-ref>[<cr refid="MEP_L_bib2">2</cr>,<cr
refid="MEP_L_bib4">4</cr>]</cross-ref>
3. <cross-ref>[<cr refid="MEP_L_bib5">5</cr>-<cr
refid="MEP_L_bib7">7</cr>]</cross-ref>
the required output is as follows:
1. <cross-refs refid="bib5 bib6 bib7 bib21 bib22 bib23 bib24">[5-7,
21-24]</cross-refs>
2. <cross-refs refid="bib2 bib4">[2, 4]</cross-refs>
3. <cross-refs refid="bib5 bib6 bib7">[5-7]</cross-refs>
I have tried this with the following code:
<xsl:template match="cross-ref">
<xsl:choose>
<xsl:when test="contains(.,'-')">
<ce:cross-refs>
<xsl:attribute name="refid">
<xsl:if test="cr/@refid[contains(., 'bib')]">
<xsl:variable name="start"
select="cr[following-sibling::text()[1] =
'-']/@refid/xs:integer(substring-after(.,'MEP_L_bib'))"/>
<xsl:variable name="end"
select="cr[preceding-sibling::text()[1] =
'-']/@refid/xs:integer(substring-after(.,'MEP_L_bib'))"/>
<xsl:value-of select="for $i in $start to $end return
concat('bib', $i)"/>
</xsl:if>
</xsl:attribute>
<xsl:apply-templates/>
</ce:cross-refs>
</xsl:when>
<xsl:otherwise>
<ce:cross-refs>
<xsl:attribute name="refid">
<xsl:value-of select="substring-after(cr[1]/@refid,'MEP_L_')"/>
<xsl:for-each select="cr[position() != 1]">
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after(@refid,'MEP_L_')"/>
</xsl:for-each>
</xsl:attribute>
<xsl:apply-templates/>
</ce:cross-refs>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
When I execute the above code i am getting the following error:
XPTY0004: A sequence of more than one item is not allowed as the
first operand of 'to' (5, 21)
I have tried with
<xsl:for-each select="$start and $end">
<xsl:value-of select="for $i in $start to $end return concat('bib', $i)"/>
</xsl:for-each>
Even this also not working. Please help me in the solving the above problem.
Regards,
Ganesh
--~------------------------------------------------------------------
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>
--~--