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

Re: Having problem matching ranges

Subject: Re: Having problem matching ranges
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 20 Jul 2006 06:34:01 -0700
270 type file
I am not sure what exactly you want to achieve, but since the subject
says "matching ranges", do have a look at a solution I provided a few
days ago for the "factory-products-quotas matching problem":

http://www.stylusstudio.com/xsllist/200607/post30270.html



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.


On 7/20/06, Jeff Sese <jsese@xxxxxxxxxxxx> wrote:
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:choose>
<xsl:when test="@n[matches(.,'-')]">
<xsl:variable name="min" as="xs:integer">
<xsl:value-of select="number(substring-before(@n,'-'))"/>
</xsl:variable>
<xsl:variable name="max" as="xs:integer">
<xsl:value-of select="number(substring-after(@n,'-'))"/>
</xsl:variable>
<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:call-template>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<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:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<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"/>
</xsl:element>
</xsl:template>

main source:

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

commentary.file:

<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.
Thanks,
Jeff

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