ID: 48009 Updated by: [email protected] Reported By: tenkei at mailinator dot com -Status: Open +Status: Bogus Bug Type: XSLT related Operating System: Linux PHP Version: 5.2.9 New Comment:
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 If you want the output XML to be formatted nicely (by default output is compact) you need to do $doc->formatOutput = true; before calling SaveXML() method. Previous Comments: ------------------------------------------------------------------------ [2009-04-17 21:17:05] tenkei at mailinator dot com Description: ------------ An XSLTProcessor object imports a stylesheet that will output XML using the XHTML1 strict doctype system, then has its transformToDoc() method called on a DOMElement object. The DOMDocument object returned by the method will not produce XML with linebreaks or indentation when saveXML() is called. Reproduce code: --------------- [ XSL ] <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" /> <xsl:template match="/Test"> <html> <head> <title>Test Page</title> </head> <body>This is a test.</body> </html> </xsl:template> </xsl:stylesheet> [ XML ] <Test /> [ PHP ] $proc = new XSLTProcessor(); $xslt = new DOMDocument(); $xslt->load( 'transform.xsl' ); $proc->importStylesheet( $xslt ); $xml = new DOMDocument(); $xml->load( 'file.xml' ); $doc = $proc->transformToDoc( $xml ); print $doc->saveXML(); Expected result: ---------------- <?xml version="1.0"?> <!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"> <head> <title>Test Page</title> </head> <body>This is a test.</body> </html> Actual result: -------------- <?xml version="1.0"?> <!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"><head><title>Test Page</title></head><body>This is a test.</body></html> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48009&edit=1
