The xsltproc command can't produce an xhtml output, and in html output it can't produce a xhtml valid <br /> or <img /> tags. Reproduce: XML <?xml version="1.0"?> <figures> <figure image="horse.png">Horses on the praerie</figure> </figures> XSL: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output encoding="UTF-8" method="html" indent="yes" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="figure"> <img> <xsl:attribute name="src"> <xsl:value-of select="@image" /> </xsl:attribute> <xsl:attribute name="alt"> <xsl:value-of select="." /> </xsl:attribute> </img> </xsl:template> </xsl:stylesheet> Produced: <img src="horse.png" alt="Horses on the praerie"> So, the close / tag is omitted, but when i want use XSLT's in valid XHTML environment, it due invalidate the complete document. From my aspect, it's a bug of libxslt, because the XSL standard requires the correct code generation.
AFAIK, your example is wrong in the sense that xsltproc is rightfully generating html (and not xhtml like you'd like). To get xhtml, here is what I used to do : <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0" > <xsl:output method="xml" media-type="text/xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="DTD/xhtml1-strict.dtd" indent="yes" encoding="ISO-8859-1" /> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ... Tested here and works as expected.
Indeed, what Gilles points out is true. Your stylesheet declares the "html" output method explicitely, which behaves just as you describe. For more information, see <http://www.w3.org/TR/xslt#section-HTML-Output-Method>.
No, because i don't want generate a full html page, just only a 'snippet'. I writing a webpage in python and my data is comes from xml. But, the full page is will generated by python, because some data is comes from MySQL (what i cant access from XML - of course). So, i need to the libxslt generate me a VAILD XHTML snippet - what i written in my example. Yes, if i include the things what do you written, the xsltproc is generates a valid XHTML page. But, i must be skip the header (such as <!DOCTYPE>, <html>, <head>, etc.), because it has been sent. Yes, i know, it's a very extreme problem. But i hope, i found a some resoulution. I google-ed over the week, and what i found, not works. :( (In reply to comment #1) > AFAIK, your example is wrong in the sense that xsltproc is rightfully > generating html (and not xhtml like you'd like). > > To get xhtml, here is what I used to do : > > <?xml version="1.0" encoding="ISO-8859-1" ?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns="http://www.w3.org/1999/xhtml" > version="1.0" > > > <xsl:output method="xml" > media-type="text/xml" > doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" > doctype-system="DTD/xhtml1-strict.dtd" > indent="yes" > encoding="ISO-8859-1" /> > > <xsl:template match="/"> > <html xmlns="http://www.w3.org/1999/xhtml"> > > <head> > ... > > > Tested here and works as expected. >
tweaking the xsl, you can get the following result : <?xml version="1.0"?> <img src="horse.png" alt="Horses on the praerie"/> but I'm quite sure you can't get less because xsltproc will only produce valid xml document. This means you'll always get the xml header. But that's not too difficult to cut out. If you're not satisfied please bring the issue upstream.
In order to remove the XML declaration from the results, you can use the 'omit-xml-declaration' attribute on the 'output' element. For example, your stylesheet could include something like: <xsl:output encoding="UTF-8" method="xml" omit-xml-declaration="yes" indent="yes" /> Anyway, Garami, I suggest that if you have further questions regarding your project, you post them on better suited places such as the Gentoo forums, or mailing lists related to XML/XSLT or Python.
Oh, very, very thanks. I will continue an asking questions in other way, this clear. Really thanks a lot of help. Sinc: G. (In reply to comment #5) > In order to remove the XML declaration from the results, you can use the > 'omit-xml-declaration' attribute on the 'output' element. For example, your > stylesheet could include something like: > > <xsl:output encoding="UTF-8" > method="xml" > omit-xml-declaration="yes" > indent="yes" /> > > Anyway, Garami, I suggest that if you have further questions regarding your > project, you post them on better suited places such as the Gentoo forums, or > mailing lists related to XML/XSLT or Python. >