#31062 [NEW]: Wrong XSLT with xmlns.

From: Date: Sat, 11 Dec 2004 23:34:38 +0000
Subject: #31062 [NEW]: Wrong XSLT with xmlns.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70049@lists.php.net to get a copy of this message
From:             swappp at yandex dot ru
Operating system: 
PHP version:      5.0.2
PHP Bug Type:     XSLT related
Bug description:  Wrong XSLT with xmlns.

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 bug report at http://bugs.php.net/?id=31062&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31062&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31062&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31062&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31062&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31062&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31062&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31062&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31062&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31062&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31062&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=31062&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=31062&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31062&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31062&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31062&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31062&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31062&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31062&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31062&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#70049) next »