php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30448 exsl:document does not create directories
Submitted: 2004-10-15 16:46 UTC Modified: 2004-10-16 13:21 UTC
From: michiel at trendserver dot nl Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5.0.2 OS: Debian
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: michiel at trendserver dot nl
New email:
PHP Version: OS:

 

 [2004-10-15 16:46 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-16 13:21 UTC] chregu@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC