php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24168 XSL functions 'forget' current node position after absolute path argument
Submitted: 2003-06-13 03:39 UTC Modified: 2003-06-13 15:08 UTC
From: christian dot hang at web dot de Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.3.2 OS: Solaris 5.7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: christian dot hang at web dot de
New email:
PHP Version: OS:

 

 [2003-06-13 03:39 UTC] christian dot hang at web dot de
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-13 07:36 UTC] sniper@php.net
Did you happen to change the libxslt/libxml versions the same time..? You're not using the latest of them.


 [2003-06-13 10:18 UTC] chregu@php.net
Hi

this is not a php bug. PHP itself does not handle anything in XSLT-Processing, it's all libxslt's work. Please upgrade to the latest libxslt libraries and if there's still a problem, report it to the libxslt mailing list (to be found at http://xmlsoft.org)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC