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=21008>.
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=21008

Parameter value disappears

           Summary: Parameter value disappears
           Product: XalanJ2
           Version: 2.0.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: org.apache.xalan
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Having a input xml

<ELEMENT> value1 </ELEMENT>
<ELEMENT> value2 </ELEMENT>
<ELEMENT> value3 </ELEMENT>

and an xsl

...
<xsl:for-each select="./ELEMENT">
  <xsl:apply-templates select=".">
        <xsl:with-param name="pos" select="position()"/>  
  </xsl:apply-templates>
</xsl:for-each>
        

<xsl:template match="ELEMENT">
    <xsl:param name="pos"/>
    <xsl:value-of select="$pos"/>
</xsl:template>



The value of $pos in the template is 0, for each ELEMENT.
The work around is to assign "position()" to a variable in the for-each

<xsl:for-each select="./ELEMENT">
  <xsl:apply-templates select=".">
        <xsl:variable name="var" select="position()"/>
        <xsl:with-param name="pos" select="$var"/>  
  </xsl:apply-templates>
</xsl:for-each>

The bug doesn't occur when using xsltproc. The xalan component is used
with the fop renderer (on the comand line with the -xml and -xsl options, which
permit to produce the FO using xerces and xalan, and produce the output in PDF
in one pass).

Reply via email to