Subject: Re: [xsl] Having problem matching ranges From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Thu, 20 Jul 2006 06:34:01 -0700 |
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":
-- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence.
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(.,'-'))<=$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(.,'-'))<=$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(.,'-'))<=$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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Having problem matching r, Michael Kay | Thread | [xsl] using xsl:import or document(, Georges Schmitz |
Re: [xsl] xsl:analyze-string explan, David Carlisle | Date | Re: [xsl] xsl:analyze-string explan, David Carlisle |
Month |