Divide and Conquer XSL

N

Norman Barker

Hi,

I am trying to use the DVC algorithm detailed at
http://www.topxml.com/code/default.asp?p=3&id=v20020107050418

had a few problems, the document is structured as
:
:
<sql:row>
<sql:date>YYYYMMMDD</sql:date>
</sql:row>
<sql:row>
<sql:date>YYYYMMMDD</sql:date>
</sql:row>
:
:

where YYYYMMDD is a valid xsd:datetime, there are thousands of
these rows, so using a for-each is a bit slow, eventually I want
to compare two times (the current time and the preceding time),
to produce a document consisting of <difference> elements where
the value is the difference in the times.

Using a simple recursive template also causes a stack overflow
with Xalan (known error).

My implementation of DVC is as below, and it should work but it
also causes a stack overflow! My questions are what is wrong
:),and will the DVC result when doing differencing compare 2
adjcent nodes?

<xsl:template name="timesteps">
<!-- rows is the set of sql:row -->
<xsl:param name="rows"/>
<xsl:param name="rowcount" select="count($rows)"/>
<xsl:choose>
<xsl:when test="$rowcount = 2">
<!-- print out 2 times, will print out date difference
when this eventually works -->
<xsl:copy-of select="$rows[1]"/>
<xsl:copy-of select="$rows[2]"/>
</xsl:when>
<xsl:eek:therwise>
<xsl:variable name="cntHalf"
select="floor($rowcount div 2)"/>

<xsl:variable name="vValue1">
<xsl:call-template name="timesteps">
<xsl:with-param name="rows"
select="$rows[position() &lt;= $cntHalf]"/>
</xsl:call-template>
</xsl:variable>

<xsl:variable name="vValue2">
<xsl:call-template name="timesteps">
<xsl:with-param name="rows"
select="$rows[position() > $cntHalf]"/>
</xsl:call-template>
</xsl:variable>

</xsl:eek:therwise>
</xsl:choose>
</xsl:template>

Many thanks,

Norman Barker
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XSL :: page value assignment 0
XSL node as string 1
newbie xsl / xslt question 2
News Ticker 2
XSL Grouping 0
xsl totals composed from variables 5
Nested call-templates 1
XSL recursion problem 1

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top