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 -->
<xslaram name="rows"/>
<xslaram 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>
<xsltherwise>
<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() <= $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>
</xsltherwise>
</xsl:choose>
</xsl:template>
Many thanks,
Norman Barker
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 -->
<xslaram name="rows"/>
<xslaram 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>
<xsltherwise>
<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() <= $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>
</xsltherwise>
</xsl:choose>
</xsl:template>
Many thanks,
Norman Barker