Edit report at http://bugs.php.net/bug.php?id=53965&edit=1

 ID:                 53965
 Comment by:         clarkwise at gmail dot com
 Reported by:        clarkwise at gmail dot com
 Summary:            <xsl:include> cannot find files w/ relative paths
                     when loaded w/ "file://"
 Status:             Open
 Type:               Bug
 Package:            XSLT related
 Operating System:   Windows XP
 PHP Version:        5.2.17
 Block user comment: N
 Private report:     N

 New Comment:

Yes, the same thing happens for all currently available versions of PHP
5.3 (5.3.0 - 5.3.5).



As a note, libxslt is compiled against libxml 2.6.32 in all PHP 5.3.x
versions, while the bundled libxml is 2.7.x, as is the case with PHP
5.2.9 and greater.


Previous Comments:
------------------------------------------------------------------------
[2011-02-15 14:47:11] cataphr...@php.net

PHP 5.2 is not supported anymore. Does this also affect PHP 5.3?

------------------------------------------------------------------------
[2011-02-08 23:46:12] clarkwise at gmail dot com

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 this bug report at http://bugs.php.net/bug.php?id=53965&edit=1

Reply via email to