PHP 7.1.0 Release Candidate 4 Released


(PHP 4 >= 4.0.5)

xslt_set_baseSet the base URI for all XSLT transformations


void xslt_set_base ( resource $xh , string $uri )

Sets the base URI for all XSLT transformations, the base URI is used with Xpath instructions to resolve document() and other commands which access external resources. It is also used to resolve URIs for the <xsl:include> and <xsl:import> elements.



The XSLT processor link identifier, created with xslt_create().


The base URI to be used.

Return Values

No value is returned.


Version Description
4.3.0 As of PHP 4.3.0, the default base URI is the directory of the executing script. In effect, it is the directory name value of the __FILE__ constant. The default base URI is less predictable with older versions.



Please note that file:// is needed in front of the path when using Windows.

add a note add a note

User Contributed Notes 3 notes

h0bby1 at yahoo dot com
8 years ago
i use xslt and page can be generated in two mode, one using <? xml-stylesheet href='page.xsl' >, one other using the php sablotron lib, the first one use path relative to the xsl file for includes , but the second with sablotron consider all the includes as relative to the set base path, is there any way to get sablotron to resolve include as relative to xslt file instead of the set_base for all files ?
edmon at oohaa dot net
12 years ago
$filebase = 'file://' . getcwd () . '/xsl/';
   xslt_set_base($xsltproc, $filebase);

file:// is needed for linux too.
php 4.3.8
Kelvin Cheng
12 years ago
It works great on my windows platform as below.

= xslt_create();
$fileBase = 'file://' . getcwd () . '/';
xslt_set_base ( $xh, $fileBase );



Actually, it make use of the getcwd() to get the current directory. Hope it can help.
To Top