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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC