#31062 [Bgs]: Wrong XSLT with xmlns.

From: Date: Wed, 15 Dec 2004 17:48:07 +0000
Subject: #31062 [Bgs]: Wrong XSLT with xmlns.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70278@lists.php.net to get a copy of this message
ID: 31062 User updated by: swappp at yandex dot ru Reported By: swappp at yandex dot ru Status: Bogus Bug Type: XSLT related PHP Version: 5.0.2 New Comment: Thanks. But it is the simplified code. Origianl: $dom_html = DOMDocument::loadHTML('<div xmlns="http://www.w3.org/1999/xhtml">'.$content.'</div>'); $xp = new DOMXPath($dom_html); $body = $xp->query("/html/body/*"); foreach ($body as $tag) { $tag = $element->appendChild($element->ownerDocument->importNode($tag, true)); } LoadHTML() don't support XHTML? And why loadHTML don't set document namespace? P.S. Sorry for my bad English. Previous Comments: ------------------------------------------------------------------------ [2004-12-14 17:13:26] rrichards@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php non-namespace aware functions used ------------------------------------------------------------------------ [2004-12-12 00:34:23] swappp at yandex dot ru Description: ------------ DOMDocument::load($xml_doc_node->saveXML()); It works normal... Reproduce code: --------------- $xml_doc_node = new DOMDocument('1.0', "UTF-8"); $xml_style = $xml_doc_node->createProcessingInstruction('xml-stylesheet'); $xml_doc_node->appendChild($xml_style); $xml_style->nodeValue = 'href="html.xsl" type="text/xsl"'; $xml_page = $xml_doc_node->createElement('document'); $xml_doc_node->appendChild($xml_page); $element = $xml_page->appendChild(new DOMElement('old-html')); $div = $element->appendChild(new DOMElement('div', 'test')); $div->setAttribute('xmlns','http://www.w3.org/1999/xhtml'); $xsl = DOMDocument::loadXML('<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" encoding="UTF-8"/> <xsl:template match="/document"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru"><body><xsl:apply-templates/></body></html> </xsl:template> <xsl:template match="/document/old-html"><xsl:copy-of select="*"/></xsl:template> </xsl:stylesheet>'); $proc = new xsltprocessor; $proc->importStyleSheet($xsl); echo $proc->transformToXML($xml_doc_node); Expected result: ---------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru"> <body> <div>test</div> </body> </html> Actual result: -------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru"> <body> <div xmlns="" xmlns="http://www.w3.org/1999/xhtml">test</div> </body> </html> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31062&edit=1

« previous php.bugs (#70278) next »