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

Re: Something similar to managing behavior with a va

Subject: Re: Something similar to managing behavior with a variable
From: "Luke Shannon" <lshannon@xxxxxxxxxxxxxxx>
Date: Tue, 5 Apr 2005 14:22:11 -0400
futurebrand toronto
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[@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@xxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, April 05, 2005 1:54 PM
Subject: Re:  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)
>
>
> ======================================================================
> Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
> 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
> ======================================================================

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.