You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2001/11/24 02:50:56 UTC
DO NOT REPLY [Bug 5057] New: -
position() function returns incorrect context node index.
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=5057>.
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=5057
position() function returns incorrect context node index.
Summary: position() function returns incorrect context node
index.
Product: XalanJ2
Version: 2.0.0
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Major
Priority: Other
Component: org.apache.xalan.processor
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: ajarrett@pacbell.net
Below are the XML and XSL sections required to reproduce the bug discovered
with the position() function. I used the JAXP interfaces to do a serverside
transformation producing a StreamResult containg the resulting HTML. The
problem occurs when the position() function is used to access the current node
index in a given context set. In this case, position returns completely
nonsensical numbers. If there are six nodes in the set, position() will
return the following series of results when called in the context of each node
(2..4..6..8..12..14) The MSXML30 and MSXML40 parsers work correctly.
<!-- XML doc section begin -->
<?xml-stylesheet type="text/xsl" standalone="yes" ?>
<PAGE>
<HEADER>
<COLUMN type="0" formattype="1">Sceanrio</COLUMN>
<COLUMN type="0" formattype="0">Category</COLUMN>
<COLUMN type="3" formattype="8">Modified</COLUMN>
<COLUMN type="1" formattype="6">Net Profit</COLUMN>
<COLUMN type="1" formattype="3">Price</COLUMN>
<COLUMN type="1" formattype="4">$ Change</COLUMN>
<COLUMN type="1" formattype="5">% Change</COLUMN>
<COLUMN type="2" formattype="2">Status</COLUMN>
<COLUMN type="1" formattype="7">Actions</COLUMN>
</HEADER>
<ROWS>
<ROW>
<ROWITEM>John's Scenario</ROWITEM>
<ROWITEM>Category Candy w/Line Price</ROWITEM>
<ROWITEM>12/12/1999</ROWITEM>
<ROWITEM>78585858534999.909</ROWITEM>
<ROWITEM>2.575</ROWITEM>
<ROWITEM>-.575</ROWITEM>
<ROWITEM>.25</ROWITEM>
<ROWITEM>Optimized</ROWITEM>
<ROWITEM>Recalc</ROWITEM>
</ROW>
</ROWS>
</PAGE>
<!-- XML doc section end-->
<!--XSL section Begin-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="PAGE">
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="css/buttonandmenu.css"/>
<link rel="STYLESHEET" type="text/css" href="css/stack.css"/>
<link rel="STYLESHEET" type="text/css" href="css/table.css"/>
<link rel="STYLESHEET" type="text/css" href="css/page.css"/>
<link rel="STYLESHEET" type="text/css" href="css/form.css"/>
</head>
<body>
<xsl:apply-templates select="ROWS"/>
</body>
</html>
</xsl:template>
<xsl:template match="ROWS">
<div class="TableContainer">
<div class="tableHeader">
<xsl:apply-templates select="preceding-sibling::HEADER" />
</div>
<div class="vScrollArea">
<xsl:apply-templates />
</div>
</div>
</xsl:template>
<xsl:template match="COLUMN">
<!-- store type info about the current node -->
<xsl:variable name="type" select="current()/@type"/>
<xsl:variable name="formattype" select="current()/@formattype"/>
<span>
<xsl:choose>
<xsl:when test="$type = '0'"> <!--string type-->
<xsl:choose>
<xsl:when test="$formattype = -1"> <!--string w/ image-->
<xsl:attribute name="class">thObjects</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '0'"> <!--string w/ image--
>
<xsl:attribute name="class">thCategory</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '1'"> <!--string w/ image--
>
<xsl:attribute name="class">thScenario</xsl:attribute>
</xsl:when>
<xsl:otherwise> <!--unknown format-->
<xsl:attribute name="class">thObjects</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$type = '1'"> <!--long -->
<xsl:choose>
<xsl:when test="$formattype = '2'"> <!--image-->
<xsl:attribute name="class">thStatus</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '3'"> <!--price #.##-->
<xsl:attribute
name="class">thDollar</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '4'"> <!--cost #.###-->
<xsl:attribute name="class">thDollar</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '5'"> <!--percent-->
<xsl:attribute name="class">thPercent</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '6'"> <!--net profit-->
<xsl:attribute name="class">thNetProfit</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '7'"> <!--actions-->
<xsl:attribute name="class">thActions</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="$type = '2'"> <!--double -->
<xsl:choose>
<xsl:when test="$formattype = '2'"> <!--image-->
<xsl:attribute name="class">thStatus</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '3'"> <!--price-->
<xsl:attribute
name="class">thDollar</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '4'"> <!--cost-->
<xsl:attribute name="class">thDollar</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '5'"> <!--percent-->
<xsl:attribute name="class">thPercent</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '6'"> <!--net profit-->
<xsl:attribute name="class">thNetProfit</xsl:attribute>
<xsl:value-of select="format-number(., '#,##0.00')"/>
</xsl:when>
<xsl:when test="$formattype = '7'"> <!--actions-->
<xsl:attribute name="class">thActions</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="$type = '3'"> <!--date or time type -
->
<xsl:choose>
<xsl:when test="$formattype = '8'"> <!--time-only type -->
<xsl:attribute
name="class">thModifiedDate</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '9'"> <!--data&time type -->
<xsl:attribute
name="class">thModifiedDate</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '10'"><!--date-only type -->
<xsl:attribute
name="class">thModifiedDate</xsl:attribute>
</xsl:when>
<xsl:otherwise> <!--unknown type -->
<xsl:attribute
name="class">thModifiedDate</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
<xsl:value-of select="."/>
</span>
</xsl:template>
<xsl:template match="ROW">
<div>
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<xsl:attribute name="class">tableRow</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">tableRowStripe</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates />
</div>
</xsl:template>
<xsl:template match="ROWITEM">
<!-- store type info about the current
node found in the corresponding column
-->
<xsl:variable name="pos" select="position()"/>
<xsl:variable name="type" select="/PAGE/HEADER/COLUMN[$pos]/@type"/>
<xsl:variable name="formattype" select="/PAGE/HEADER/COLUMN
[$pos]/@formattype"/>
position=<xsl:value-of select="$pos"/>
<!--swith on type then formattype-->
<span>
<xsl:choose>
<!--string type-->
<xsl:when test="$type = '0'">
<xsl:choose>
<xsl:when test="$formattype = -1"> <!--string w/ image-->
<xsl:attribute name="class">objects</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '0'"> <!--string w/ image--
>
<xsl:attribute name="class">category</xsl:attribute>
</xsl:when>
<xsl:when test="$formattype = '1'"> <!--string w/ image--
>
<xsl:attribute name="class">scenario</xsl:attribute>
</xsl:when>
<xsl:otherwise> <!--unknown format-->
<xsl:attribute name="class">objects</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="."/>
</xsl:when>
<!--long -->
<xsl:when test="$type = '1'">
<xsl:choose>
<xsl:when test="$formattype = '2'"> <!--image-->
<xsl:attribute name="class">status</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="$formattype = '3'"> <!--price #.##-->
<xsl:attribute name="class">dollar</xsl:attribute>
<xsl:value-of select="format-number(., '$#,##.00')"/>
</xsl:when>
<xsl:when test="$formattype = '4'"> <!--cost #.###-->
<xsl:attribute name="class">dollar</xsl:attribute>
<xsl:value-of select="format-number(., '$#,##.00')"/>
</xsl:when>
<xsl:when test="$formattype = '5'"> <!--percent-->
<xsl:attribute name="class">percent</xsl:attribute>
<xsl:value-of select="format-number(., '##.##%')"/>
</xsl:when>
<xsl:when test="$formattype = '6'"> <!--net profit-->
<xsl:attribute name="class">netProfit</xsl:attribute>
<xsl:value-of select="format-number(., '$#,##0.00')"/>
</xsl:when>
<xsl:when test="$formattype = '7'"> <!--actions-->
<xsl:attribute name="class">actions</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise> <!--default-->
<xsl:attribute name="class">percent</xsl:attribute>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!--double -->
<xsl:when test="$type = '2'">
<xsl:choose>
<xsl:when test="$formattype = '2'"> <!--image-->
<xsl:attribute name="class">status</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="$formattype = '3'"> <!--price-->
<xsl:attribute
name="class">dollar</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="$formattype = '4'"> <!--cost-->
<xsl:attribute name="class">dollar</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="$formattype = '5'"> <!--percent-->
<xsl:attribute name="class">percent</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="$formattype = '6'"> <!--net profit-->
<xsl:attribute
name="class">netProfit</xsl:attribute>
<xsl:value-of select="format-number(., '#,##0.00')"/>
</xsl:when>
<xsl:when test="$formattype = '7'"> <!--actions-->
<xsl:attribute name="class">actions</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise> <!--default-->
<xsl:attribute name="class">percent</xsl:attribute>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!--date or time type -->
<xsl:when test="$type = '3'"> <!--date or time type -
->
<xsl:choose><!--these are place holders for more styles-->
<xsl:when test="$formattype = '8'"> <!--time-only type -->
<xsl:attribute
name="class">modifiedDate</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="$formattype = '9'"> <!--data&time type -->
<xsl:attribute
name="class">modifiedDate</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:when test="$formattype = '10'"><!--date-only type -->
<xsl:attribute
name="class">modifiedDate</xsl:attribute>
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise> <!--unknown type -->
<xsl:attribute
name="class">modifiedDate</xsl:attribute>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</span>
</xsl:template>
</xsl:stylesheet>
<!--XSL section Begin-->