From: phpbugs at xmlnode dot com Operating system: Debian 2.6 stable PHP version: 5.2.5 PHP Bug Type: XSLT related Bug description: transformToXml does not properly close tags when stylesheet output is xml
Description: ------------ It's pretty basic, I have an xsl stylesheet with an output method of xml and an encoding of iso-8859-1 (which doesn't matter) using xhtml11 as the doctype, but the same is seen for other xhtml doctypes. When I call transformToXML I get tags like this: <hr> <br> <link ...> when I call transformToURI() I get the proper tags <hr/> <br /> <link />, etc. If I call transformToDoc() and then use saveXML() I still see the open tags <hr> <br> <link ...>, but if I call transformToDoc and then save() the tags are correct. I would have thought it was a browser-specific issue, but I've tried every browser available to me (7 total across multiple platforms) My guess is that internally save and transformToURI; which work, call the same method, but that transformToXML and saveXML which don't work call the same somewhat broken method. Reproduce code: --------------- stylesheet (condensed): <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" media-type="text/html" doctype-public="-//W3C//DTD XHTML 1.1 //EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd" omit-xml-declaration="yes" encoding="iso-8859-1"/> <xsl:template match="/"><html xml:lang="en"> <head><title>whatever</title></head><body><br/><hr/><img src='somesource'/></body></html></xsl:template> $xml = new DOMDocument('1.0'); $xml->loadXML('<PAGE/>'); $xsl = new DOMDocument('1.0); $xsl->load(<path to stylesheet>); // you'll need to set this $proc = new XsltProcessor(); $proc->importStylesheet($xsl); echo $proc->transformToDoc($xml); Expected result: ---------------- <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd"> <html xml:lang="en"><head><title>whatever</title></head><body><br/><hr/><img src="somesource"/></body></html> I should note that this is the output from either transformToURI($xml, <path>) or $dom = transformToDOC($xml); $dom->save(<path>); In fact if you want you can just change $dom->save(path) to $dom->saveXML() and you'll get completely different results. Actual result: -------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd"> <?xml version="1.0" encoding="iso-8859-1"?><html xml:lang="en"> <head><title>whatever</title></head> <body> <br><hr> <img src="somesource"> </body> </html> You'll notice that not only are the tags not closed the XML declaration is in a different spot. I assume you'll ask, because I know I would, but I'm running the absolute latest libxml2 (2.6.31) and libxsl (1.1.22), compiled everything last night (2/26/2008) saw the behavior before upgrading -- Edit bug report at http://bugs.php.net/?id=44279&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44279&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44279&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44279&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44279&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44279&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44279&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44279&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44279&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44279&r=support Expected behavior: http://bugs.php.net/fix.php?id=44279&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44279&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44279&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44279&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44279&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44279&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44279&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44279&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44279&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44279&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44279&r=mysqlcfg