php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20177 xslt_process adds arg: into all document calls on the xsl sheet.
Submitted: 2002-10-30 15:04 UTC Modified: 2002-11-01 19:39 UTC
From: vulture at consult-scs dot com Assigned: msopacua (profile)
Status: Closed Package: XSLT related
PHP Version: 4.2.3 OS: FreeBSD 4.7
Private report: No CVE-ID: None
 [2002-10-30 15:04 UTC] vulture at consult-scs dot com
Sablot 0.96 and expat 1.95 installed
php-4.2.3:
./configure --enable-xslt --with-xslt-sablot --with-mysql --with-imap --with-apxs2=/usr/local/apache2/bin/apxs --with-expat=/usr/local --with-gettext --with-xml --with-mcrypt --enable-ftp --with-tsrm-pth

Problem: When using xslt_process and a arg:xxx, any xslt document() calls will point to arg:(and what was in the document call)

Example xsl sheet code:
<xsl:apply-templates select="document('/websites/xxx/htdocs/xml/messages.xml')//message[@id='nf-comp']/text[@xml:lang='en']"/>
would attempt to open:
arg:/websites/xxx/htdocs/xml/messages.xml

If I call the xsl sheet in from a file then it worked fine.

Origanal Code/Syntax Used:
<?
$xh = xslt_create();
// set xml file to be used with translation
$xmlfile=$GLOBALS["DOCUMENT_ROOT"]."/xml/product.xml";

// load dynamic xsl sheet to be used with translation
$xslstyle="http://".$GLOBALS["SERVER_NAME"]."/styles/product-detail.php?id=".$GLOBALS["HTTP_GET_VARS"]["id"];
$fp = fopen($xslstyle, "r");
$xsltdata["xsldata"]=fread($fp, 500000);
fclose($fp);

// do the translation
$result = xslt_process($xh, $xmlfile, 'arg:xsldata', NULL, $xsltdata);
?>

Fix I used to get around this:
add this line after $xh = xslt_create();
xslt_set_base($xh, "file:///");

Working Code:
<?
$xh = xslt_create();

// Added to fix trying to open arg:(and the file name)
xslt_set_base($xh, "file:///");
// End Added

// set xml file to be used with translation
$xmlfile=$GLOBALS["DOCUMENT_ROOT"]."/xml/product.xml";

// load dynamic xsl sheet to be used with translation
$xslstyle="http://".$GLOBALS["SERVER_NAME"]."/styles/product-detail.php?id=".$GLOBALS["HTTP_GET_VARS"]["id"];
$fp = fopen($xslstyle, "r");
$xsltdata["xsldata"]=fread($fp, 500000);
fclose($fp);

// do the translation
$result = xslt_process($xh, $xmlfile, 'arg:xsldata', NULL, $xsltdata);
?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-30 15:08 UTC] vulture at consult-scs dot com
Using Apache 2.0.43
 [2002-10-31 05:40 UTC] msopacua@php.net
It's foremost a documentation problem. But we're looking into making it more intuitive.
However - using a combination of a filepath and 'arg:/' is discouraged, when the documents use external files. Relative paths are resolved based on their file location. Using 'arg://' the file location is currently undefined - this will be set to $_SERVER['PATH_TRANSLATED'] in future versions and documented properly.

The problem is, that this will not only apply to the xsl sheet in your example, but also the XML file. This is a design limitation in the Sablotron library, as xslt_set_base applies to the $xh resource, not a specific file.
 [2002-11-01 19:39 UTC] msopacua@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

There's a test as well (bug20177.phpt).
We now set the baseuri, for the 'arg' scheme, to the currently executed file. This should be intuitive, but may still be confusing, when dealing with includes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 21:01:29 2024 UTC