DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6284>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6284

variable defined outside of template

           Summary: variable defined outside of template
           Product: XalanJ2
           Version: 2.2.x
          Platform: PC
        OS/Version: Windows 9x
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Xalan
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Using Xalan 2.2D14.
With the following stylesheet and xml input file, it appears you need to refer 
to $myStopAt somewhere before you call 'findDups'. If everything works you get a 
message saying 'found a duplicate', but if you delete the variable 'dummy' you 
don't get this message.

This is the stylesheet -

<!--stylesheet to track down bug in Xalan. Delete the reference to $myStopAt
 in template match to exhibit bug. If lastMove or myStopAt is defined simply
 by select='100' for example, bug goes away -->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
<xsl:output method="xml"/>

<xsl:variable name="lastMove">
  <xsl:for-each select="/Go/GoGame/Nodes/Black">
    <xsl:sort select="@number" data-type="number" order="descending"/>
    <xsl:if test="position()=1">
      <xsl:value-of select="@number"/>
    </xsl:if>
  </xsl:for-each>
</xsl:variable>

<xsl:variable name="myStopAt">
 <xsl:choose>
  <xsl:when test="$lastMove=''">
   <xsl:value-of select='0'/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:value-of select="$lastMove"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:variable>

<xsl:key name="ids" match="/Go/GoGame/Nodes/Black" use="@at"/>

<xsl:template match="/">
 <xsl:variable name="dummy" select="$myStopAt"/>
 <!--if you delete the line above, findDups doesn't find any duplicates-->
 <xsl:call-template name="findDups"/>
</xsl:template>

<xsl:template name="findDups">
  <xsl:for-each select="/Go/GoGame/Nodes/Black
 [(generate-id(.)!=generate-id(key('ids',@at))) and @number&lt;=$myStopAt]">
  <xsl:message>found a duplicate</xsl:message>
 </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Input xml -

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="go.xsl" type="text/xsl"?>
<Go>
<GoGame>
<Nodes>
<Black number="1" at="R4"/>
<Black number="2" at="R4"/>
</Nodes>
</GoGame>
</Go>

Reply via email to