From:             
Operating system: Windows XP
PHP version:      5.2.17
Package:          XSLT related
Bug Type:         Bug
Bug description:<xsl:include> cannot find files w/ relative paths when loaded 
w/ "file://"

Description:
------------
I upgraded from PHP 5.2.5 (using binaries from windows.php.net), and now
the <xsl:include>s in some of my stylesheets stopped working. Testing each
version in succession, I discovered that it worked up through 5.2.8 and
does not work in 5.2.9+. I now get the following three errors for each
<xsl:include>.



Warning: XSLTProcessor::importStylesheet(): I/O warning : failed to load
external entity "file%3A/C%3A/xsltest/include.xsl" in C:\xsltest\xsl.php on
line 11



Warning: XSLTProcessor::importStylesheet(): compilation error: file
file%3A//C%3A/xsltest/collection.xsl line 3 element include in
C:\xsltest\xsl.php on line 11



Warning: XSLTProcessor::importStylesheet(): xsl:include : unable to load
file%3A/C%3A/xsltest/include.xsl in C:\xsltest\xsl.php on line 11



Interestingly, in the first and third

errors, it is displaying the file:// protocol with only one slash

instead of the correct two.



IMPORTANT NOTE: This problem only occurs when the primary XSL document is
loaded with the "file://" protocol with one too few slashes. (See sample
PHP file.) Correctly, there should be three slashes when loading a local
file, where my existing code only has two (i.e., "file://C:/path"). Files
used to load, but now they don't. I don't see what changed in 5.2.9 to
cause that.



Ultimately, the question is why the main stylesheet loads but its
<xsl:include>s do not, as they are in the same directory. Either they
should both load or neither should load.



---

Another thing I noticed is that the up until PHP 5.2.9, libxslt was
compiled against the same version of

libxml that was included with PHP. But starting with PHP 5.2.9,

libxslt was compiled against an older version of libxml than that

which was included with PHP. See below:



    5.2.5

    libxml Version => 2.6.26

    libxslt compiled against libxml Version => 2.6.26



    5.2.8



    libxml Version => 2.6.32

    libxslt compiled against libxml Version => 2.6.32



    === versions differ starting at 5.2.9 ===

    5.2.9

    libxml Version => 2.7.3

    libxslt compiled against libxml Version => 2.6.32



    5.2.16

    libxml Version => 2.7.7

    libxslt compiled against libxml Version => 2.6.32



It might be a mere coincidence that in 5.2.9 both my code stopped working
and these versions differ, but it seemed worth noting.

Test script:
---------------
(based on XSL example at
http://us.php.net/manual/en/xsl.examples-collection.php)



C:\xsltest\xsl.php

=====

<?php



$xml = new DOMDocument();

$xml->load('collection.xml');



$xsl = new DOMDocument();

$xsl->load('file://C:/xsltest/collection.xsl'); // <xsl:include>s fail

//$xsl->load('file:///C:/xsltest/collection.xsl'); // <xsl:include>s work



$proc = new XSLTProcessor;

$proc->importStyleSheet($xsl);



echo $proc->transformToXML($xml);





=====

C:\xsltest\collection.xsl

=====

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>



 <xsl:include href="include.xsl"/>



 <xsl:param name="owner" select="'Nicolas Eliaszewicz'"/>

 <xsl:output method="html" encoding="iso-8859-1" indent="no"/>

 <xsl:template match="collection">

  Hey! Welcome to <xsl:value-of select="$owner"/>'s sweet CD collection! 

  <xsl:apply-templates/>

 </xsl:template>

</xsl:stylesheet>



=====

C:\xsltest\include.xsl

=====

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

 <xsl:template match="cd">

  <h1><xsl:value-of select="title"/></h1>

  <h2>by <xsl:value-of select="artist"/> - <xsl:value-of
select="year"/></h2>

  <hr />

 </xsl:template>

</xsl:stylesheet>



=====

C:\xsltest\collection.xml (same as on example page above)

=====

<?xml version="1.0"?>

<collection>

 <cd>

  <title>Fight for your mind</title>

  <artist>Ben Harper</artist>

  <year>1995</year>

 </cd>

 <cd>

  <title>Electric Ladyland</title>

  <artist>Jimi Hendrix</artist>

  <year>1997</year>

 </cd>

</collection>

Expected result:
----------------
include.xsl is loaded, and the script works, yielding:



  Hey! Welcome to Nicolas Eliaszewicz's sweet CD collection!



 <h1>Fight for your mind</h1><h2>by Ben Harper - 1995</h2><hr>

 <h1>Electric Ladyland</h1><h2>by Jimi Hendrix - 1997</h2><hr>

Actual result:
--------------
include.xsl is not loaded (despite the fact that collection.xsl is loaded),
yielding these errors:



Warning: XSLTProcessor::importStylesheet(): I/O warning : failed to load
external entity "file%3A/C%3A/xsltest/include.xsl" in C:\xsltest\xsl.php on
line 11



Warning: XSLTProcessor::importStylesheet(): compilation error: file
file%3A//C%3A/xsltest/collection.xsl line 3 element include in
C:\xsltest\xsl.php on line 11



Warning: XSLTProcessor::importStylesheet(): xsl:include : unable to load
file%3A/C%3A/xsltest/include.xsl in C:\xsltest\xsl.php on line 11





-- 
Edit bug report at http://bugs.php.net/bug.php?id=53965&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53965&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53965&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53965&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53965&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53965&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53965&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53965&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53965&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53965&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53965&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53965&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53965&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53965&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53965&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53965&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53965&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53965&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53965&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53965&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53965&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53965&r=mysqlcfg

Reply via email to