php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34034 XSLT Processor can't append element new xsl:include
Submitted: 2005-08-08 10:19 UTC Modified: 2005-08-08 10:27 UTC
From: sfs at immune dot dk Assigned:
Status: Not a bug Package: XSLT related
PHP Version: 5.0.4 OS: Windows XP SP2
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: sfs at immune dot dk
New email:
PHP Version: OS:

 

 [2005-08-08 10:19 UTC] sfs at immune dot dk
Description:
------------
When using DOM to create a new <xsl:include> and insert it in the xslt document php comes up with a error as seen below.

Reproduce code:
---------------
<?php
$xsl = new DOMDocument('1.0', 'UTF-8');
$test = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
				xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" indent="yes"/>
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
</xsl:stylesheet>
EOF;
$xsl->loadXML($test);

$import = $xsl->createElement('xsl:import');
$import->setAttribute('href', 'login.xsl');

$xsl->documentElement->insertBefore($import, $xsl->documentElement->firstChild);

echo $xsl->saveXML();

$html = new XSLTProcessor();
$html->importStylesheet($xsl);
?>

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:import href="login.xsl"/>
	<xsl:output method="html" indent="yes"/>
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
</xsl:stylesheet>
<br />
<b>Warning</b>:  Found a top-level element xsl:import with null namespace URI in <b>D:\steffen\frontend\test.php</b> on line <b>23</b><br />

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:import href="login.xsl"/>
	<xsl:output method="html" indent="yes"/>
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
</xsl:stylesheet>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-08 10:27 UTC] sfs at immune dot dk
You have to use DOMDocument::createElementNS instead, if anyone have the same problem see:

http://bugs.php.net/bug.php?id=29811
and
http://www.ctindustries.net/dom/domxsl.txt
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 19 15:01:25 2020 UTC