xsl-list
[Top] [All Lists]

How to implement Divide and Conquer Algo on this template !! Getting Callstack overflow error

2003-09-18 16:34:49
Hi,

The is regarding Callstack overflow error.

Dimitrie suggested to implement Divide and Conquer Solution to avoid such a 
problem.

I saw his example at this site.
http://www.topxml.com/code/default.asp?p=3&id=v20020107050418


How do i write DVC algorithm for the following Call-Template. Here I am having 
data also in the parameter. And my input file is going to be in GBs and every 
time the "names" param in the following snippet is going to huge number atlest 
more than 1000 as there are 10 attributes in each node and there will be 1000 
or more nodes like that.

I am trying to get unique attribute names for say node "SecondNode" which can 
repeat any number of times.

<!-- Getting all possible attribute names for SecondName -->
xsl:variable name="ResColNames" select="/Root/FirstNode/SecondNode/@*"/>

<!-- Calling template to get unique names with delimiter -->
xsl:variable name="uniqueColumnNamesRes">
<xsl:call-template name="findUniqueNamesForNodesWithAtt">
<xsl:with-param name="names" select="$ResColNames"/>
<xsl:with-param name="uniqueNames"/>
<xsl:with-param name="i">0</xsl:with-param>
</xsl:call-template>
</xsl:variable>

The following is the template which is called.

<!-- This is to find unique Attribute Names for SecondNode --> <xsl:template 
name="findUniqueNamesForNodesWithAtt">
<xsl:param name="names"/>
<xsl:param name="uniqueNames"/>
<xsl:param name="i"/>
<xsl:choose>
<xsl:when test="$i &lt;= count($names)">
<xsl:variable name="newUniqueName">
<xsl:choose>
<xsl:when test="contains($uniqueNames, name($names[$i]))">
<xsl:value-of select="$uniqueNames"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($uniqueNames,'`',name($names[$i]))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="findUniqueNamesForNodesWithAtt">
<xsl:with-param name="names" select="$names"/>
<xsl:with-param name="uniqueNames" select="$newUniqueName"/>
<xsl:with-param name="i" select="$i + 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($uniqueNames,'`')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


In the above Called template how do i use Divide and Conquer algorithm. My 
whole solution is relying on this kind of template only so if somebody please 
show me how to implement DVC algorithm it will be highly appreciated.

Thanks in the anticipation that I will get some reply from you.

Eagerly waiting for your reply.

Regards,
Dipesh


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list