At 9:48 -0500 23/06/05, Dan Feather wrote:
Hello again,
        As per John's suggestion I am now using the SQL Extension
instead of my own custom XMLReader, and it is nifty. However, I am
running into an interesting issue that I have a feeling would be more
easily solved if I had more experience with XSLT. Maybe you guys can
give me a hint.

[snip]

I attempted something using recursion, and came close... here is
something similar to what I was doing:


[snip]

So, my recursion works... kinda... I just lose track of what row I
already processed when I bubble back up to the row-set match... so I
repeat my match on rows I already pulled the special number out of...

I know this email is a bit lengthy, but I am really not sure how to
handle something like this, but I can't imagine I am the first person
that has needed to do this, and I imagine it is a common problem. Anyone
have any pointers? I appreciate it!

Assuming your data is small enough, you can use a for-each main loop rather than an apply-templates one. (It won't work for large sets of data, since for-each builds an entire nodelist at the start.)

Here's some code I used for collecting together all the product rows with the same ProductId:

    <xsl:for-each select="$table/sql/row-set/row">
      <xsl:variable name="pos" select="position()"/>
      <xsl:variable name="ProductId"
          select="[EMAIL PROTECTED]'ProductId']/text()" />
      <!-- Ignore duplicate ProductIds in this outer loop -->
      <xsl:if
          test="$pos=1 or $table/sql/row-set/row[$pos - 1]/col
          [EMAIL PROTECTED]'ProductId']/text() != $ProductId" >
        <!-- For each non-duplicate Id, process all its rows together -->
        <xsl:call-template name="ProcessProduct">
          <xsl:with-param name="rows"
              select="$table/sql/row-set/row[col
              [EMAIL PROTECTED]'ProductId']/text() = $ProductId]" />
        </xsl:call-template>
      </xsl:if>
    </xsl:for-each>

HTH.

--
 AA   III   SSS    |    Advent Information Systems Ltd.
A  A   I   S       |
AAAA   I    SS     |    Richard Grossman, Systems Architect
A  A   I      S    |
A  A  III  SSS     |    e-mail:    <[EMAIL PROTECTED]>

Reply via email to