RE: [xsl] net.sf.saxon.trans.DynamicError

Subject: RE: [xsl] net.sf.saxon.trans.DynamicError
From: Santosh N <ss1722@xxxxxxxxx>
Date: Fri, 29 Jul 2005 12:52:00 -0700 (PDT)
Here is the code I am using to create a pagination. I don't get this
error all the time it happens once in a while.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">

<xsl:variable name="totalRowCount" select="count(Results/Row)"/>
<xsl:variable name="totalAllocCount"
select="sum(/Results/Row/allocCount)"/>
<xsl:variable name="selectedRowCount"
select="count(Results/Row[*[name()=$groupColumn]=$groupColumnValue
and
filterFlag=0])"/>
<xsl:variable name="allocCount"
select="sum(Results/Row[*[name()=$groupColumn]=$groupColumnValue and
filterFlag=0]/allocCount)"/>

<xsl:template name="Pager">

<xsl:param name="mode"/>

<xsl:if test="$selectedRowCount > 0">

<xsl:variable name="curPage" select="1"/>
<xsl:variable name="lastCount" select="1"/>

<table border="0" width="100%">
<tr>
<td>
	<xsl:choose>
		<xsl:when test="$mode='Order'">	
			<xsl:call-template name="OrderFooter"/>
		</xsl:when>
		<xsl:when test="$mode='Trade'">
			<xsl:call-template name="TradeFooter"/>
		</xsl:when>
	</xsl:choose>
</td>

<td>
<xsl:if test="number($selectedRowCount) &gt; number($maxRows)">
<table cellpadding="0" cellspacing="0" border="0" align="center">
<tr height="15">
<td class="textmid1">
<xsl:choose>
	<xsl:when test="number($rowNumber)-number($maxRows) &gt; 0">
		<A class="pagerHref">
			<xsl:attribute
name="href">JavaScript:goToPage(<xsl:value-of
select="number($rowNumber)-number($maxRows)"/>,<xsl:value-of
select="$maxRows"/>)</xsl:attribute>
			&lt;&lt;Prev
		</A>
		&#160;
	</xsl:when>
	<xsl:otherwise>
		&lt;&lt;Prev&#160;
	</xsl:otherwise>
</xsl:choose>
</td>

<xsl:for-each select="1 to $selectedRowCount">
	<xsl:if test="position() = 1">
	<td class="textmid1">
		<xsl:variable name="curPage" select="1"/>
		&#160;
		<xsl:choose>
		<xsl:when test="position() = number($rowNumber)">
			<xsl:value-of select="$curPage"/> 
		</xsl:when>
		<xsl:otherwise>
			<A class="pagerHref">
			<xsl:attribute
name="href">JavaScript:goToPage(<xsl:value-of
select="$curPage"/>,<xsl:value-of
select="$maxRows"/>)</xsl:attribute>
			<xsl:value-of select="$curPage"/> 
			</A>
		</xsl:otherwise>
		</xsl:choose>
	</td>
	</xsl:if>
	<xsl:if test="position() mod number($maxRows) = 0">
	<td class="textmid1">
		<xsl:variable name="curPage" select="(position() div
number($maxRows)) + 1"/>
		<xsl:variable name="lastCount" select="position()"/>
		&#160;
		<xsl:choose>
		<xsl:when test="(position()+1) = number($rowNumber)">
			<xsl:value-of select="$curPage"/>
		</xsl:when>
		<xsl:otherwise>
			<A class="pagerHref">
			<xsl:attribute
name="href">JavaScript:goToPage(<xsl:value-of
select="position()+1"/>,<xsl:value-of
select="$maxRows"/>)</xsl:attribute>
			<xsl:value-of select="$curPage"/>
			</A>
		</xsl:otherwise>
		</xsl:choose>
	</td>
	</xsl:if>		
</xsl:for-each>

<td class="textmid1">
<xsl:choose>
	<xsl:when test="number($rowNumber)+number($maxRows) &lt;=
number($selectedRowCount)">
		&#160;
		<A class="pagerHref">
			<xsl:attribute
name="href">JavaScript:goToPage(<xsl:value-of
select="number($rowNumber)+number($maxRows)"/>,<xsl:value-of
select="$maxRows"/>)</xsl:attribute>
			Next&gt;&gt;
		</A>
	</xsl:when>
	<xsl:otherwise>
		&#160;Next&gt;&gt;
	</xsl:otherwise>
</xsl:choose>
</td>

</tr>
</table>
</xsl:if>

</td>
</tr>
</table>
</xsl:if>

</xsl:template>

<xsl:template name="OrderFooter">
	<xsl:variable name="curMax" select="number($maxRows) +
number($rowNumber) -1"/>
			
	<table>
	<tr>
		<td>
			<B>Page No: <xsl:value-of
select="format-number((number($rowNumber) div number($maxRows)) +
1,'#0')"/></B>
			<span id="legend"
style="font-weight:normal;font-size:12px;color:#5c5c5c;line-height:14px;
text-align:right;font-family: Arial, Helvetica, sans-serif;"> 
				&lt;&lt;
				<xsl:value-of
select="$rowNumber"/><xsl:text> thru </xsl:text>
				<xsl:choose>
					<xsl:when test="number($curMax)
&lt;= number($selectedRowCount)">
						<xsl:value-of
select="$curMax"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of
select="$selectedRowCount"/>
					</xsl:otherwise>
				</xsl:choose>
				&gt;&gt;
			</span>
		</td>
	</tr>
	<tr>
		<td>
			<B>Total Blocks: <xsl:value-of
select="$selectedRowCount"/><xsl:text>/</xsl:text><xsl:value-of
select="$totalRowCount"/>&#160;,&#160;</B>
			<B>Allocations: <xsl:value-of
select="$allocCount"/><xsl:text>/</xsl:text><xsl:value-of
select="$totalAllocCount"/></B>
		</td>
	</tr>
	
	</table>
</xsl:template>

<xsl:template name="TradeFooter">
	<xsl:variable name="curMax" select="number($maxRows) +
number($rowNumber) -1"/>
			
	<table>
	<tr>
		<td>
			<B>Page No: <xsl:value-of
select="format-number((number($rowNumber) div number($maxRows)) +
1,'#0')"/></B>
			<span id="legend"
style="font-weight:normal;font-size:12px;color:#5c5c5c;line-height:14px;
text-align:right;font-family: Arial, Helvetica, sans-serif;"> 
				&lt;&lt;
				<xsl:value-of
select="$rowNumber"/><xsl:text> thru </xsl:text>
				<xsl:choose>
					<xsl:when test="number($curMax)
&lt;= number($selectedRowCount)">
						<xsl:value-of
select="$curMax"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of
select="$selectedRowCount"/>
					</xsl:otherwise>
				</xsl:choose>
				&gt;&gt;
			</span>
		</td>
	</tr>
	<tr>
		<td>
			<B>Total Trades: <xsl:value-of
select="$selectedRowCount"/><xsl:text>/</xsl:text><xsl:value-of
select="$totalRowCount"/>&#160;,&#160;</B>
		</td>
	</tr>
	
	</table>
</xsl:template>

</xsl:stylesheet>

-----Original Message-----
From: Sam D. Chuparkoff [mailto:sdc@xxxxxxxxxx] 
Sent: Friday, July 29, 2005 11:34 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] net.sf.saxon.trans.DynamicError

On Fri, 2005-07-29 at 06:02 -0700, Santosh N wrote:
> Hi All,
> 
> I am getting the below error while transforming to HTML. Please
> advise if any one has encountered the similar problem and possible
> cause for this error. I am using XSLT2.0 and the SAXON parser.
> 
> net.sf.saxon.trans.DynamicError: Circular definition of variable
> selectedRowCount

I think you probably will want to post a stripped-down version of
some
code that exhibits this problem.

I didn't look further than the error above. I don't know any other
way
of throwing this error except writing a circular variable definition.
The simplest would be:

  <xsl:variable name="selectedRowCount" select="$selectedRowCount"/>

Equally bad is:

  <xsl:variable name="someOtherVariable" select="$selectedRowCount"/>
  <xsl:variable name="selectedRowCount" select="$someOtherVariable"/>

Note that even if you've something as ghastly as the first example in
a
stylesheet, saxon won't throw an error unless you try to evaluate an
expression that references selectedRowCount. This depends on the rest
of
the stylesheet and the input. (There may well be exceptions; I
wouldn't
know.)

Hope that helps.

sdc




		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 

Current Thread