473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Divide and Conquer XSL

Hi,

I am trying to use the DVC algorithm detailed at
http://www.topxml.com/code/default.a...20020107050418

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:otherwise>
<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:otherwise>
</xsl:choose>
</xsl:template>

Many thanks,

Norman Barker
Jul 20 '05 #1
0 1556

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jack Smith | last post by:
Hello, I am working on the following problem. I need a divide and conquer algorithm to solve the following problem. Any help is appreciated. I have a set of coordinates (x,y) and each...
6
by: Nobody | last post by:
I have some code that I am trying to optimize for speed... trying to squeeze every last CPU cycle out... I remembered an old trick where dividing & multiplying can be sped up by using bitshifts...
5
by: per.nordlow | last post by:
Hey there! I want to multiply/divide (shift) a float with variable containing a power-of-two value: 2, 4, 8, 16, .... Is there such a function in the C standard library or the glibc library...
1
by: urvi | last post by:
Hi... following is a problem i need to solve using divide and conquer method(recursive)..can anybody help me..? You are to organize a tournament involving n teams. Each team must play each...
4
by: shuisheng | last post by:
Dear all, Assume I have two big arrays A and B. And I want to element-wise divide A by B. When an element of B is zero, the results are also zero. Such as A = { 2, 4, 0, 6} B = { 1, 0, 0, 2}...
40
by: Spiros Bousbouras | last post by:
Do you have an example of an implementation where sizeof(short int) does not divide sizeof(int) or sizeof(int) does not divide sizeof(long int) or sizeof(long int) does not divide sizeof(long long...
1
by: Justin.Velazquez | last post by:
Hello everyone, I'm not really new to programming but my bitwise skills definately need work. I came across a problem I've been trying to figure out for fun. I'm trying to write a routine...
1
by: nadine | last post by:
I need some help writing an algorithm (pseudocode is fine too) for a divide-and-conquer technique for determining the position of the max element in an unsorted array. Any help would be appreciated
12
by: rajm2019 | last post by:
Without using /,% and * operators. write a function to divide a number by 3. itoa() function is available
5
by: seemanikam | last post by:
Can anyone suggest me how to devise an efficient divide-and-conquer algorithm for the Tower-of-Hanoi problem when the disks are colored alternately red and blue, and with the extra rule that no disk...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.