ID: 30448
Updated by: [EMAIL PROTECTED]
Reported By: michiel at trendserver dot nl
-Status: Open
+Status: Bogus
Bug Type: XSLT related
Operating System: Debian
PHP Version: 5.0.2
New Comment:
XSLT (and XML/DOM) uses the PHP Stream implementation
for accessing/writing files. And they don't create
directories, if they don't exist... (it's the same as
fopen("/foo/bar/bla.txt","w"); )
Nothing we can and want to do about that. Implement your
own streamwrapper in PHP, which creates the directories
and use that.
Previous Comments:
------------------------------------------------------------------------
[2004-10-15 16:46:30] michiel at trendserver dot nl
Description:
------------
The PHP5 XSL extension does not seem to create directories when using
the <exsl:document> element.
Reproduce code:
---------------
XML file (test.xml):
<?xml version="1.0"?>
<a>
<b>test1</b>
<b>test2</b>
</a>
XSLT file (test.xsl):
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="html" indent="yes" encoding="US-ASCII"/>
<xsl:template match="a">
<exsl:document href="output/test.html" method="html">
<xsl:for-each select="b">
<p><xsl:value-of select="."/></p>
</xsl:for-each>
</exsl:document>
</xsl:template>
</xsl:stylesheet>
PHP file (exslt.php):
<?php
$xml = new DomDocument;
$xml->load('test.xml');
$xsl = new DomDocument;
$xsl->load('test.xsl');
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl);
$proc->transformToXML($xml);
?>
Expected result:
----------------
Running 'xsltproc test.xsl test.xml' gives a directory 'output' with
file 'test.html' containing '<p>test1</p><p>test2</p>'.
Running 'php exslt.php' should give the same result.
Actual result:
--------------
Warning: XSLTProcessor::transformToXml(output/test.html): failed to
open stream: No such file or directory in /var/www/experiment/exslt.php
on line 10
Warning: No such file or directoryruntime error: file
/var/www/experiment/test.xsl element document in
/var/www/experiment/exslt.php on line 10
Warning: xsltDocumentElem: unable to save to output/test.html in
/var/www/experiment/exslt.php on line 10
Note: when an empty directory 'output' is created before running 'php
exslt.php', the file 'test.html' is created correctly.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30448&edit=1