Bug #53050 [Opn->Bgs]: processing instructions won't append correctly

From: Date: Wed, 13 Oct 2010 08:35:59 +0000
Subject: Bug #53050 [Opn->Bgs]: processing instructions won't append correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155138@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53050&edit=1

 ID:                 53050
 Updated by:         aharvey@php.net
 Reported by:        jameswithers89 at gmail dot com
 Summary:            processing instructions won't append correctly
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            DOM XML related
 Operating System:   Linux
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

This works fine; you just have to call insertBefore with the right
reference node. In this case, replacing:

	$Document->documentElement->insertBefore($IeXhtml);

with:

	$Document->insertBefore($IeXhtml, $Document->doctype);

will take care of that.

Not a bug -> closing.


Previous Comments:
------------------------------------------------------------------------
[2010-10-13 02:25:10] jameswithers89 at gmail dot com

Description:
------------
In order to make my XHTML compatible with Internet Explorer it is
recommended (http://www.w3.org/MarkUp/2004/xhtml-faq#ie) to have
<?xml-stylesheet type="text/xsl" href="copy.xsl"?> as a processing
instruction. However, trying to append this does not work as expected.


Test script:
---------------
	$Implementation = new DOMImplementation();
	$Doctype = $Implementation->createDocumentType("html");
	$Document =
$Implementation->createDocument("http://www.w3.org/1999/xhtml", "html",
$Doctype);
	// Workaround for IE XHTML issues:
http://www.w3.org/MarkUp/2004/xhtml-faq#ie
	$IeXhtml = $Document->createProcessingInstruction("xml-stylesheet",
"type=\"text/xsl\" href=\"copy.xsl\"");
	$Document->documentElement->insertBefore($IeXhtml);
	$Head = $Document->createElement("head");
	$Title = $Document->createElement("title", "My page");
	$Head->appendChild($Title);
	$Document->documentElement->appendChild($Head);
	$Body = $Document->createElement("body");
	$Script = $Document->createElement("script", "");
	$Script->setAttribute("src", "test.js"); 
	$Script->setAttribute("type", "text/javascript");
	$Body->appendChild($Script);
	$Document->documentElement->appendChild($Body);
	echo $Document->saveXML();

Expected result:
----------------
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My page</title>
</head>
<body>
<script src=test.js" type="text/javascript"></script>
</body>
</html>


Actual result:
--------------
<?xml version="1.0"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<?xml-stylesheet type="text/xsl" href="copy.xsl"?>
<head>
<title>My page</title>
</head>
<body>
<script src=test.js" type="text/javascript"></script>
</body>
</html>


------------------------------------------------------------------------



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


Thread (2 messages)

« previous php.bugs (#155138) next »