From:             christian dot hang at web dot de
Operating system: Linux (Debian woody)
PHP version:      4.3.2
PHP Bug Type:     DOM XML related
Bug description:  XSL functions 'forget' current node position after absolute path 
argument

Description:
------------
After an upgrade (from 4.3.0 to 4.3.2), some of the XSL transformation
(handled by domxml) where not working correctly anymore.

It seems, that XSL functions (like concat) forget the current node, that
they should use to evualate relative XPath-Expression in their arguments,
when an absolute Path is given in a prior argument.

The example code demonstrates that behavior (compare description of
Expected result and Actual result). 

A quick workaround is the addition of the current()-function in the
relative path expressions, as that will fix the problem. But as far as I
know, that is not required by the standard.

If one switches the two arguments (concat(@nr, //testnode/@test)),
everything works fine, the current() is not necessary and @nr is evaluated
correctly. As the order of the arguments has an effect on the path
evaluation (which it should not), I figure that there is problem.

The versions of the libraries used:

DOM/XML API Version  20020815  
libxml Version  20419  
HTML Support  enabled  
XPath Support  enabled  
XPointer Support  enabled  
DOM/XSLT  enabled  
libxslt Version  1.0.20  
libxslt compiled against libxml Version  2.4.24  
DOM/EXSLT  enabled  
libexslt Version  1.0.20  

I have to admit that I cannot compare the library versions used here with
the ones I used for 4.3.0 version where everything worked okay (system
crashed - long and ugly story), so it might very well be a problem of the
libraries instead of the domxml extenstion.

Reproduce code:
---------------
$xml = "<?xml version=\"1.0\" ?><root><testnode test=\"somevalue\"><node
nr=\"1\"/><node nr=\"2\"/><node nr=\"3\"/></testnode></roo\
t>";
$xml_doc = domxml_open_mem($xml);

$xsl_text="<?xml version=\"1.0\" ?>
<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\";
version=\"1.0\">
    <xsl:output method=\"xml\"/>
    <xsl:template match=\"root\">
        <new_root>
            <xsl:for-each select=\"testnode/node\">
                <xsl:value-of select=\"concat(//testnode/@test, @nr)\"/>
-
            </xsl:for-each>
        </new_root>
    </xsl:template>
</xsl:stylesheet>";

$xsl = domxml_open_mem($xsl_text);
$xsl_doc = domxml_xslt_stylesheet_doc($xsl);
$res = $xsl_doc->process($xml_doc);

Expected result:
----------------
A dump of the $res result tree should produce the following

<?xml version="1.0"?>
<new_root>somevalue1 - 
            somevalue2 - 
            somevalue3 - 
            </new_root>

and it does, if the concat expression in the example script is changed to
"concat(//testnode/@test, current()/@nr)"



Actual result:
--------------
A dump of the $res result tree does produce the following

<?xml version="1.0"?>
<new_root>somevalue - 
            somevalue - 
            somevalue - 
            </new_root>

The nr-attribute value is not concatenated to the value of the
test-attribute in testnode.


-- 
Edit bug report at http://bugs.php.net/?id=24168&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24168&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24168&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24168&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24168&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24168&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24168&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24168&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24168&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24168&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24168&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24168&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24168&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24168&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24168&r=gnused

Reply via email to