xsl-list
[Top] [All Lists]

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

2003-09-19 11:22:40
Read more about the application of the Muenchian method -- there are many
posts in this list solving exactly your problem.

Briefly put, use two keys -- one matching "Table/@TableName" elements and
the other matching Column/@Name the parent of which has a "Table"
grandparent with specific value of the "TableName" attribute.

Hint:

The use attribute of the last xsl:key will be:

  concat(../../../@TableName, '|', .)


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL




"Dipesh Khakhkhar" <dkhakhkh(_at_)mailbox(_dot_)syr(_dot_)edu> wrote in message
news:3F6CDEA0(_at_)OrangeMail(_dot_)(_dot_)(_dot_)
Hi,

To avoid the Callstack error for huge input files. I have to change my
algorithm to find unique names. I do it for finding unique attribute names
and
unique attribute values.

Now using Munechian method how do i find unique values for the TableName
and
for each TableName how do i find unique ColumnName in the following xml.

Input
-----


<Root>
<FNode>
<SNode>
<Table TableName="fName>
  <Row>
   <Column Name="ColName1"/>
   <Column Name="ColName2"/>
  </Row>
  <Row>
   <Column Name="ColName1"/>
   <Column Name="ColName3"/>
   <Column Name="ColName4"/>
  </Row>
</Table>
<Table TableName="SecondTname">
<Row>
   <Column Name="ColName1"/>
   <Column Name="ColName2"/>
   <Column Name="ColName3"/>
   <Column Name="ColName4"/>

  </Row>
  <Row>
   <Column Name="ColName1"/>
   <Column Name="ColName5"/>
   <Column Name="ColName6"/>
  </Row>
</Table>
</SNode>
<SNode>
<Table TableName="fName>
  <Row>
   <Column Name="ColName1"/>
   <Column Name="ColName2"/>
  </Row>
  <Row>
   <Column Name="ColName1"/>
   <Column Name="ColName5"/>
   <Column Name="ColName6"/>
  </Row>
</Table>
<Table TableName="SecondTname">
  <Row>
   <Column Name="ColName2"/>
   <Column Name="ColName3"/>
  </Row>
  <Row>
   <Column Name="ColName7"/>
   <Column Name="ColName8"/>
  </Row>
</Table>
<Table TableName="ThirdTname">
  <Row>
   <Column Name="ColName1"/>
   <Column Name="ColName2"/>
  </Row>
 </Table>
</SNode>
</FNode>
</Root>


There can be any number of Table nodes within SNode and there will be any
number of SNodes within FNode.

My previous logic was to find the unique table names and then for each
table
name find unique Column names. As pointed out, I was using inefficient
code to
the same, it was working fine when there were limited number of Table
nodes
but i got Callstack overflow error when number of Table node increased. As
Dimitre told, then i moved to implement grouping using xsl:key.

I am formin xml file as output. For the above xml file the output  will be

Desired output
--------------

<Root>
<Tables>
<Table Name="FNode">
<!-- Here column node corresponding to unique attribute names for FNode
will
be written. For simplicity this is dropped from the current xml. I am able
to
get this output -->
</Table>
<!-- Similarly for second table -->
<Table Name="SNode">
</Table>
<Table Name="fName">
<Column Name="ColName1"/>
<Column Name="ColName2"/>
<Column Name="ColName3"/>
<Column Name="ColName4"/>
<Column Name="ColName5"/>
<Column Name="ColName6"/>
</Table>
<Table Name="SecondTname">
<Column Name="ColName1"/>
<Column Name="ColName2"/>
<Column Name="ColName3"/>
<Column Name="ColName4"/>
<Column Name="ColName5"/>
<Column Name="ColName6"/>
<Column Name="ColName7"/>
<Column Name="ColName8"/>
</Table>
<Table Name="ThirdTname">
<Column Name="ColName1"/>
<Column Name="ColName2"/>
</Table>
</Tables>
</Root>

I hope, I am clear in explaining my problem.

Any help to get the solution in efficent way will be highly appreciated. I
wrote the solution but it is not efficient thats why i have to change the
entire xsl now.

Eagerly waiting for reply.

Regards,
Dipesh




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






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