Hi Wendell;
Here is what I have now (it doesn't compile because of $cur_path):
<xsl:for-each select="$resultstring[contains($cur_path, 'mtrd')]">
<xsl:sort select="DATA/VERSION/ITEM[(_at_)NAME='SCORE']" order="descending"
data-type="number" />
<xsl:variable name="cur_path" select="concat(@PATH, @FNAME)"/>
<xsl:variable name="position" select="position()" />
<xsl:call-template name="showresult">
<xsl:with-param name="position" select="$position"/>
<xsl:with-param name="page" select="$page"/>
</xsl:call-template>
</xsl:for-each>
My problem is part of my condition is based on information from the node I'm
on while processing.
Is it possible to loop through and create a node set of the nodes that meet
the condition and than loop through again writing them? Is there a better
way?
Thanks,
Luke
----- Original Message -----
From: "Wendell Piez" <wapiez(_at_)mulberrytech(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Tuesday, April 05, 2005 1:54 PM
Subject: Re: [xsl] Something similar to managing behavior with a variable
Luke,
The easiest way to fix this, if it's possible, is to construct your
condition such that it occurs in the 'select' expression that chooses the
nodes to process, rather than selecting a larger set and then using an
explicit conditional to filter them.
That is, instead of:
<xsl:for-each select="$nodes">
<xsl:if test="$condition">
...
</xsl:if>
...
</xsl:for-each>
do
<xsl:for-each select="$nodes[$condition]">
...
</xsl:for-each>
Then your code relying on position() will work again.
Note, this isn't always possible -- your problem may require heavier
lifting. Post again with more info (including the logic of the condition)
if this doesn't work for you.
Cheers,
Wendell
At 01:57 PM 4/5/2005, you wrote:
Hello;
I'm creating a UI that writes rows of data. The background of the row
needs
to changes every second row. I was doing it like this:
<tr align="left" valign="middle" class="grey1ColumnText">
<xsl:choose>
<xsl:when test='number($position) mod 2 != 0'>
<xsl:attribute name="class">grey1ColumnText</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">grey2ColumnText</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</tr>
My problem now is now have a condition that determines when a row is to
be
written. So, in a collection of 5 items maybe only 1 and 4 get written. I
still need a way to figure out how to alternate the background for the
rows
that actually get written. Position no longer does the trick.
I thought I could keep the previous background in a variable like below:
<tr align="left" valign="middle" class="grey1ColumnText">
<xsl:choose>
<xsl:when test="$resultBK = 'grey1ColumnText'">
<xsl:attribute name="class">grey2ColumnText</xsl:attribute>
<xsl:variable name="resultBK" select="string('grey2ColumnText')"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">grey1ColumnText</xsl:attribute>
<xsl:variable name="resultBK" select="string('grey1ColumnText')"/>
</xsl:otherwise>
</xsl:choose>
</tr>
But I have just found out you can't change the contents of a global
variable
(resultBK) after it has been defined. How can I handle this?
Thanks,
Luke
Luke Shannon | Software Developer
FutureBrand Toronto
207 Queen's Quay, Suite 400
Toronto, ON, M5J 1A7
416 642 7935 (office)
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--