Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2004, 09:01 AM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Stack overflow

Hi all!

I've the problem that I don't know how to handle with templates so that I can call a template into another (e.g. I tried to get a table into a parent table) without getting a Stack overflow

XML:
<table>
<border>5</border>
<width>50%</width>
<cellspacing>2</cellspacing>
<tr>
<td>
<width>30%</width>
<colspan>1</colspan>
<text>1.Feld</text>
</td>
<td>
<width>40%</width>
<colspan>1</colspan>
<text>2.Feld</text>
</td>
<td>
<width>40%</width>
<colspan>1</colspan>
<text></text>
</td>
<td>

<table>
<border>5</border>
<width>25%</width>
<cellspacing>2</cellspacing>
<tr>
<td>
<width>30%</width>
<colspan>1</colspan>
<text>11.Feld</text>
</td>
<td>
<width>40%</width>
<colspan>1</colspan>
<text>22.Feld</text>
</td>
</tr>
<tr>
<td>
<width>30%</width>
<colspan>3</colspan>
<text>ganz viele Fehler<text>
</td>
</tr>
</table>
</td>
</tr>
</table>

XSL:

<xsl:template match="table">
<table border="{border}" width="{width}" cellspacing="{cellspacing}">
<xsl:for-each select="tr">
<xsl:value-of select="rowspan"/><tr rowspan="{rowspan}">
<xsl:for-each select="td">
<td width="{width}" colspan="{colspan}">
<xsl:value-of select="text"/>

<xsl:apply-templates select="//table"/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>

 
Old August 31st, 2004, 09:53 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I don't know what you're trying to achieve here, but what your code actually does is that every time you process a table element (xsl:template match="table") you are asking it to process every table element in the whole document (xsl:apply-templates select="//table") including of course the table where you started. So this will give you infinite recursion (or it would, if the processor had an infinite stack).



Michael Kay
http://saxon.sf.net/
 
Old September 1st, 2004, 12:59 AM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, for your response






Similar Threads
Thread Thread Starter Forum Replies Last Post
Stack Overflow Exception?? Apocolypse2005 Visual Basic 2005 Basics 2 January 17th, 2008 07:06 PM
Recursive algorithm causing stack overflow rharris VB.NET 2002/2003 Basics 8 July 7th, 2005 12:48 PM
Resursive algorithm causing stack overflow rharris Pro VB.NET 2002/2003 1 July 4th, 2005 11:00 AM
Recursive algorithm causing stack overflow rharris VB.NET 1 July 4th, 2005 10:57 AM
C++ Stack? Spivonious C++ Programming 6 October 11th, 2004 03:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.