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

Having problem matching ranges

Subject: Having problem matching ranges
From: Jeff Sese <jsese@xxxxxxxxxxxx>
Date: Thu, 20 Jul 2006 20:05:39 +0800
date having select min date
hi! One more question before i sleep. I have this xsl:

<xsl:key name="commentary" match="node()[name()!='T_F_entry']" use="generate-id(preceding-sibling::T_F_entry[1])"/>

<xsl:template match="T_F_entry">
<xsl:variable name="id" select="@id"/>
<xsl:variable name="type" select="@type"/>
<xsl:variable name="n" select="@n"/>
<xsl:when test="@n[matches(.,'-')]">
<xsl:variable name="min" as="xs:integer">
<xsl:value-of select="number(substring-before(@n,'-'))"/>
<xsl:variable name="max" as="xs:integer">
<xsl:value-of select="number(substring-after(@n,'-'))"/>
<xsl:for-each select="$min to $max">
<xsl:variable name="ctr" as="xs:integer" select="."/>
<xsl:if test="exists(document($commentary.file)//T_F_entry[@id=$id and @type=$type and (@n[matches(.,'-') and number(substring-before(.,'-'))&lt;=$ctr and number(substring-after(.,'-'))>=$ctr] or @n=$ctr)])">
<xsl:call-template name="insert.comments">
<xsl:with-param name="idnum" select="$idnum"/>
<xsl:with-param name="id" select="$id"/>
<xsl:with-param name="type" select="$type"/>
<xsl:with-param name="n" select="$ctr"/>
<xsl:if test="exists(document($commentary.file)//T_F_entry[@id=$id and @type=$type and (@n[matches(.,'-')][number(substring-before(.,'-'))&lt;=$n][number(substring-after(.,'-'))>=$n] or @n=$n)])">
<xsl:call-template name="insert.comments">
<xsl:with-param name="idnum" select="$idnum"/>
<xsl:with-param name="id" select="$id"/>
<xsl:with-param name="type" select="$type"/>
<xsl:with-param name="n" select="$n"/>

<xsl:template name="insert.comments">
<xsl:param name="idnum"/>
<xsl:param name="id"/>
<xsl:param name="type"/>
<xsl:param name="n"/>
<xsl:element name="div">
<xsl:apply-templates select="document($commentary.file)//T_F_entry[@id=$id and @type=$type and (@n[matches(.,'-')][number(substring-before(.,'-'))&lt;=$n][number(substring-after(.,'-'))>=$n] or @n=$n)]/key('commentary',generate-id())" mode="commentary"/>

main source:

<T_F_entry id="270" type="F" n="5">
some text
<T_F_entry id="270" type="F" n="5-6">
some text


<T_F_entry id="270" type="F" n="5-6"/> some text 5-6 <T_F_entry id="270" type="F" n="5"/> some text 5 <T_F_entry id="270" type="F" n="6"/> some text 6 <T_F_entry id="270" type="F" n="7"/> some text 7

needed ouput:

<div>some text 5-6 some text 5</div>
<div>some text 5-6 some text 5 some text 6</div>

When i run the xslt i receive a cannot convert string "5-6" to a double error.

Current Thread


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.
First Name
Last Name
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-2013 All Rights Reserved.