[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

multiple range expansion

Subject: multiple range expansion
From: Ganesh Babu N <nbabuganesh@xxxxxxxxx>
Date: Mon, 22 Jun 2009 14:11:47 +0530
 multiple range expansion
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.