[xslt] Possible bug in libxslt HTMl serialization



Im pretty sure this is a bug. It might be a problem with the HTML 
serialization. I've verifeid it on Linux with the latest 1.0.22 xsltproc 
and latest libxml. Saxon gives me the expected output. xsltproc does not.

Consider this stylesheet which is designed to transform XHTML into 
non-namespaced HTML:

<xsl:stylesheet
   version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:html="http://www.w3.org/1999/xhtml";>

  <xsl:output method="html"/>

   <xsl:template match="@*|node()">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
   </xsl:template>

   <xsl:template match="html:*">
     <xsl:element name="{name(.)}">
       <xsl:apply-templates select="@*|node()"/>
     </xsl:element>
   </xsl:template>

</xsl:stylesheet>

Apply this to the XHTML 1.0 spec with xsltproc:

% xsltproc xhtmltohtml.xsl http://www.w3.org/TR/xhtml1

Here's the beginning of the output:

<html lang="en" lang="en">
<head>

Notice the double lang attribute at the top. The second one has lost the 
xml: prefix. Saxon does remember the prefix and output separate lang and 
xml:lang attributes with the same stylesheet applied to the same input 
document.

Changing the output method to xml does fix the problem; i.e. you get 
separate lang and xml:lang attributes.

Since the HTML output method isn't fully specified it's arguable that 
both xsltproc and Saxon are correct here. However, my gut is that the 
double lang attribute has to be considered a mistake, and that even in 
the html output method libxslt should be retaining the xml prefix.


--
Elliotte




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]