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

Re: table preceding row, child entry - recursion?

Subject: Re: table preceding row, child entry - recursion?
From: Steve <subsume@xxxxxxxxx>
Date: Wed, 26 Jul 2006 15:53:52 -0400
get table element
Yes, recursion is one way of doing it. I just got help with a similar
problem but basically, you pass the rows to the template and allow the
template to call itself with the new values until its spent.

Below is something I think will get you halfway there..

<xsl:template match="Record">
		<!-- running totals of hours already used   -->
		<xsl:param name="used">0</xsl:param>

<xsl:param name="usedSSA">0</xsl:param>

		<!-- running totals of quota not used   -->
		<xsl:param name="leftSSA">0</xsl:param>
		<xsl:choose>
			<!-- Capacity used up, output used and move on   -->
			<xsl:when test="(hours = $used)">
				<tr>
					<td><xsl:value-of select="service" /></td>
					<td><xsl:value-of select="round(hours)" /></td>
					<td><xsl:value-of select="round($usedSSA)" /></td>
				</tr>
				<xsl:apply-templates select="following-sibling::Record[1]">
					<xsl:with-param name="leftSSA" select="$leftSSA" />
				</xsl:apply-templates>

			</xsl:when>
			<xsl:when test="not($leftSSA = 0)">
				<xsl:choose>
					<xsl:when test="($leftSSA &gt;= (hours - $used))">
						<xsl:apply-templates select=".">
							<xsl:with-param name="used" select="hours" />
							<xsl:with-param name="usedSSA" select="($usedSSA + hours - $used)" />
							<xsl:with-param name="leftSSA" select="($leftSSA - (hours - $used))" />
						</xsl:apply-templates>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select=".">
							<xsl:with-param name="used" select="($used + $leftSSA)" />
							<xsl:with-param name="usedSSA" select="($usedSSA + $leftSSA)" />

						</xsl:apply-templates>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select=".">
					<xsl:with-param name="used" select="hours" />
					<xsl:with-param name="usedSSA" select="$usedSSA" />
				</xsl:apply-templates>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
On 7/26/06, Sonja.Hendrick@xxxxxxxxxxx <Sonja.Hendrick@xxxxxxxxxxx> wrote:
I will attempt to describe my issue that has been frustrating me...

The original table looks like this:

  <row>
  <cell>
  <cell merge="3">
  <cell>
  <cell>
  <cell>
  </row>


Transform to:


  <Mrow>
  <cell>
  <cell start merge>
  <cell>
  <cell>
  <cell>
  </Mrow>

  <Mrow>
  <cell>
  <cell continue>
  <cell>
  <cell>
  <cell>
  </Merge>

  <Mrow>
  <cell>
  <cell continue>
  <cell>
  <cell>
  <cell>
  </Merge>

  <Mrow>
  <cell>
  <cell continue>
  <cell>
  <cell>
  <cell>
  </Merge>

  The transform identifies the cell element with the 'merge' attribute
and creates
  [<cell start merge>]


What I need to do is, 1. for the following rows I need to test if the ancestor row has a child cell element with an attribute 'merge'.

  2. Ask: How many positions after the first row (the row with the @
merge) is the current row. (is it one row after, two rows after or
three
rows after if it is more than three, end loop)

  (In my example the value for the merge is 3. In the transform, the
value '3' is used for the next three rows after the initial @, at the
position of where the attribute sits, I need to create an attribute
'continue')

  3. Ask: is current position of row/cell the same as ancestor row/cell
(in the example that position is 2)

I don't know where to begin...I would appreciate any and all help.

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.