Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 174888 - dev-libs/libxslt-1.1.20 xsltproc problem
Summary: dev-libs/libxslt-1.1.20 xsltproc problem
Status: VERIFIED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: All Linux
: High normal
Assignee: Gentoo Linux Gnome Desktop Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-17 09:30 UTC by Gabor Garami
Modified: 2007-04-19 00:23 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Garami 2007-04-17 09:30:42 UTC
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.
Comment 1 Gilles Dartiguelongue (RETIRED) gentoo-dev 2007-04-17 12:52:17 UTC
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. 
Comment 2 Leonardo Boshell (RETIRED) gentoo-dev 2007-04-17 18:20:40 UTC
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>.
Comment 3 Gabor Garami 2007-04-18 06:55:27 UTC
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. 
> 

Comment 4 Gilles Dartiguelongue (RETIRED) gentoo-dev 2007-04-18 09:19:35 UTC
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.
Comment 5 Leonardo Boshell (RETIRED) gentoo-dev 2007-04-18 21:34:28 UTC
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.
Comment 6 Gabor Garami 2007-04-19 00:23:23 UTC
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.
>