Re: [xsl] Recursive call trouble

Subject: Re: [xsl] Recursive call trouble
From: Luke Jones <ljones@xxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Aug 2006 11:29:48 -0500
I'm sorry.  I'm probably not being very clear which is partly due to my
unfamiliarity with XSL and XML.  I'll try to provide more detail as to
what I'm wanting to do, along with more of my code.

=======To Do=======
I'm trying to take a dynamically created XML and convert it into a new
XML.  I would like to take specific paragraphs from the first XML, and
break up the <para> tag into a bunch of one line tags.  For Example, if
one of the <para> tags is:

<para>
This is a test paragraph to elaborate on what I'm trying to do.
Hopefully it will enable others to help me.  So I will continue to type
and type away until I have three sentences or so. 
<para>

I would want to new XML to have:

<line number=1>
This is a test paragraph to elaborate on what I'm trying to do.
</line>
<line number=2>
Hopefully it will enable others to help me.  So I will continue to type
</line>
<line number=3>
and type away until I have three sentences or so.
</line>

=====More complete example of Dynamic XML====

I don't want to paste the whole thing because its much to large.
However, I will try to paste a more complete picture of what I'm working
with.


<floordoc> 
	<bill>
		<bill-state>
			<header>
				<introduced>
				...
				</introduced>
			</header>
		</bill-state>
		<title>
			<para>
			...
			</para>
		</title>
		...
	</bill>
</floordoc>

=====XSL======

I was just showing the recursive of my XSL, but perhaps it'll make more
sense of what I'm trying to accomplish if I show more of what I've done
to make the XML to XML conversion.

	
<xsl:stylesheet ... >
	<xsl:output method="xml" indent="yes"/>
		
	<xsl:template match="floordoc">
		
		<floordoc legno="{@legno}"
			  sessiontype="{@sessiontype}"
			  sessionno="{@sessionno}"
			  documenttype="{@documenttype}">
		
<!-- I do the above also for <bill>, <bill-state>, and <header>	-->

		<title>
			<xsl:call-template name='intro'/>
		</title>
		</floordoc>
	</template>

	====Recursive part====	  	
	<xsl:template match="title" name="intro">
		<xsl:param name = "start" select="1" />
		<xsl:param name = "end" select="60" />
		<xsl:param name = "ln" select="1" />
		<xsl:variable name="num" select="string-length(.)" />
			
			<line number='{$ln}'>
				<xsl:choose>
					<xsl:when test="$end &gt; $num">
						<xsl:value-of select="substring(.,$start)"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="substring(.,$start,60)"/>
					</xsl:otherwise>
				</xsl:choose>
			</line>

			<xsl:call-template name="intro">
				<xsl:with-param name = "start" select='$start+60'/>
				<xsl:with-param name = "end" select='$end+60'/>
				<xsl:with-param name = "ln" select= '$ln+1'/>
			</xsl:call-template>
	</xsl:template>
</xsl:stylesheet>


====Acutal Error Msg======

Finally the actually error message I'm getting.

<Location of error unknown>XSLT Error <java.lang.StackOverflowError>:
null

========

This turned out to be a much longer response then I had intended.  Sorry
about that.  Thanks again for they help, and I hope I can eventually get
on the same page as you, or at least be less confusing!

Take care,
Luke

Current Thread