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

Variable node-sets in x-path predicates work incorrectly in XLTC

           Summary: Variable node-sets in x-path predicates work incorrectly
                    in XLTC
           Product: XalanJ2
           Version: 2.4Dx
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Xalan-Xsltc
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


X-Path expressions like "$period-type[@id = $period/@type]/@label" (with 
variable node-sets in predicates) don't return expected results and are 
different from results returned by intepreting X-Path.
Consider sample XML and XSLT:

XML is:
<?xml version="1.0"?>
<config>
        <period-types>
                <period-type id="fn" label="Q#"/>
        </period-types>
        <fields>
                <field name="f1">
                        <period type="fn"/>
                </field>
        </fields>
</config>

XSLT is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="xml"/>

<xsl:template match="/">
        <xsl:variable name="period-type"
select="config/period-types/period-type"/>
        <fields>
                <xsl:for-each select="config/fields/field">
                        <xsl:variable name="period" select="period"/>
                        <field name="{@name}">
                                <period type="{$period/@type}"
label="{$period-type[@id = $period/@type]/@label}"/>
                        </field>
                </xsl:for-each>
        </fields>
</xsl:template>


Using Xalan gives result (which is correct):
<?xml version="1.0" encoding="UTF-8"?>
<fields>
        <field name="f1">
                <period label="Q#" type="fn"/>
        </field>
</fields>

Using XSLTC gives result (not correct):
<?xml version="1.0" encoding="UTF-8"?>
<fields>
        <field name="f1">
                <period type="fn" label=""/>
        </field>
</fields>

As you can see, in the XSLTC result attribute @label is empty, while it
should be the same as in case of Xalan usage. So it looks like X-Path
expression "$period-type[@id = $period/@type]/@label" doesn't work correctly
in case of xsltc. To be more exact I think "$period/@type" part in predicate
is not executed right, b/c if you'd replace it with constant value
everything will be fine.

Reply via email to