<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
as for me, the most easier way to fix this:<br>
It will not cause any performance issues and possible failures with big
variables or recursions.<br>
<tt><fo:table-body><br>
<xsl:apply-templates select="<font color="#ff0000">article[1]</font>"
mode="someMode"><br>
<font color="#ff0000"> <xsl:with-param name="count"
select="1"/></font><br>
</xsl:apply-templates><br>
</tt> <tt><fo:table-body/></tt><br>
<tt><br>
<xsl:template match="article" mode="someMode"><br>
<xsl:param name="count"/><br>
<xsl:choose><br>
<xsl:when test="<font color="#3333ff">all_condition_that_you_have</font>"><br>
<fo:table-row page-break-inside="avoid">
<br>
</tt><tt><xsl:if test="(<font color="#ff0000">$count
mod
2) = 0</font>"><br>
</tt><tt><xsl:attribute
name="background-color"><font color="#3333ff">some_color</font></xsl:attribute></tt><br>
<tt> </xsl:if><br>
</tt><tt> [...]</tt><br>
<tt> </fo:table-row></tt><br>
<tt></tt><tt> <xsl:apply-templates select="<font
color="#ff0000">following-sibling::article[1]</font>"
mode="someMode"></tt><br>
<tt> <font color="#ff0000"><xsl:with-param
name="count" select="$count+1"/></font></tt><br>
<tt> </xsl:apply-templates></tt><br>
<tt> </xsl:when><br>
<xsl:otherwise><br>
</tt><tt> <xsl:apply-templates select="<font
color="#ff0000">following-sibling::article[1]</font>"
mode="someMode"></tt><br>
<tt> <font color="#ff0000"><xsl:with-param
name="count" select="$count"/></font></tt><br>
<tt> </xsl:apply-templates></tt><br>
<tt> </xsl:otherwise><br>
</tt><tt> </xsl:choose><br>
</xsl:template><br>
</tt>In other word: it process articles one after another, and if
conditions are true it give another template parameter <font
color="#ff0000">count</font> increased by one point.<br>
"someMode" in apply-templates used in case if you have special
processing of article in another place.<br>
--BS<br>
Powell, Todd wrote:
<blockquote
cite="mid12540AEF7AE4114AA1AE4D1F5DF432760D0239@HQGTNEX1.doe.local"
type="cite">
<pre wrap="">Hi Martin,
Personally, I see "recursion solutions" as a kind of a workaround for
one of XSLT's shortcomings -- namely no traditional variables -- and
they make it difficult to understand what's going on in the script (if
not for the original developer, then for any subsequent support staff
trying to take over maintenance).
AND, if you ARE talking about a really huge table, and it causes your
transformation "to exlode" (nice imagery Geoff :-), then you can't use
it at all.
I'd suggest two alternatives:
1) If you are using a parser that supports javascript scripting as
callable functions from the XSL (Microsoft's is one), you could create a
"global" javascript variable that truly does get incremented during each
table row output, and whose value can be queried to determine odd/even;
or
2) Split your XSLT process into two distinct passes: one which
sorts/filters/etc. the data into the desired order, and another which
operates on the result of the first and simply looks at the (position()
mod 2) to determine odd/even.
Each of these options have their downsides, and may prove undoable for
your situation, but I think they are more straightforward in their logic
than the recursive approach.
Hope this helps!
Regards,
Todd
================================
Todd S. Powell
Project Performance Corporation
Principal Analyst
U.S. Department of Energy
================================
</pre>
<blockquote type="cite">
<pre wrap="">David Pirkle schrieb:
</pre>
<blockquote type="cite">
<pre wrap="">You could try moving the body of your loop into a recursive template,
and then replace the for-each with a call to the template. That
would allow you to have a variable that increments for each element
that passes the filter, and you could use the modulus test on that.
-----Original Message-----
Martin Snajdr|AMAN
Sent: Tuesday, May 23, 2006 1:16 AM
To: <a class="moz-txt-link-abbreviated" href="mailto:xep-support@renderx.com">xep-support@renderx.com</a>
Subject: [xep-support] "Filtered" Select and alternating
background-color
Hi there,
i have a problem with a real huge table, which has to have
alternating background-color in each table-row.
As you can see in the following excerpt, i have to use a xsl:if to
filter the select. But doing it this way prevents the
position()-thing from working right, when the filter is active.
[..]
<fo:table-body>
<xsl:for-each select="article">
        <xsl:if test="(($filter_material='all') or
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->($filter_material!='all'
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">and
@color=$filter_material))
                                and (($filter_knaggen='all') or
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->($filter_knaggen!='all' and
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">contains(./attributevalue[@attid=$filter_knaggen_attrid]/value[@lang=
'
de'],$filter_knaggen)
))
                                and (($filter_nenngroesse='all') or
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->($filter_nenngroesse!='all'
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">and
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->contains(./attributevalue[@attid=$filter_nenngroesse_attrid]/value[@la
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">ng='de'],$filter_nenngroesse)
))
                                and (($filter_eingang='all') or
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->($filter_eingang!='all' and
</pre>
<pre wrap=""><!---->contains(./attributevalue[@attid=$filter_eingang_attrid]/value[@lang='
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">de'],$filter_eingang)
))
                                ">
        <fo:table-row page-break-inside="avoid">
        <xsl:attribute name="background-color"><xsl:if test="position()
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->mod
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">2=0">rgb-icc(255,255,255,#CMYK,0,0,0,0)</xsl:if><xsl:if
test="position() mod 2 != 0">rgb-icc(227, 231,
241,#CMYK,0.1,0.045,0,0.05)</xsl:if></xsl:attribute>
[..]
I tried to change the select to do the filtering, but since the
filter depends on passed-in params i'm not able to do this. I tried
some exslt node-set-stuff, but i didn't get to it.
Anyone any idea?
</pre>
</blockquote>
</blockquote>
<pre wrap=""><!---->
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to <a class="moz-txt-link-abbreviated" href="mailto:majordomo@renderx.com">majordomo@renderx.com</a> from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service <a class="moz-txt-link-freetext" href="http://www.renderx.com/terms-of-service.html">http://www.renderx.com/terms-of-service.html</a>
</pre>
</blockquote>
<br>
</body>
</html>
-------------------
(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to majordomo@renderx.com from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/terms-of-service.html