ID: 44279 User updated by: phpbugs at xmlnode dot com Reported By: phpbugs at xmlnode dot com Status: Bogus Bug Type: XSLT related Operating System: Debian 2.6 stable PHP Version: 5.2.5 New Comment:
Ugh. you're right. Another developer had an output handler that does a bunch of decently important stuff, but in there was a buzz-killing saveHTML(). Please consider this redacted - "the office" - season 2 :) Previous Comments: ------------------------------------------------------------------------ [2008-02-28 06:13:04] [EMAIL PROTECTED] If I run your code on a commandline PHP it does work correctly: <!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 assume, the conversion from <br/> to <br> happens somewhere else in your case, either the browser or apache. try something like wget to get the raw source of your output. My experience with the xslt extension also tells me, that this can0t be PHPs fault, I never saw something like that. Also your experience with the difference between saveXML and save tells me, that the conversion happens somewhere else. ------------------------------------------------------------------------ [2008-02-28 01:06:36] phpbugs at xmlnode dot com 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 this bug report at http://bugs.php.net/?id=44279&edit=1