Re: [xslt] LibXSLT adding annoying whitespace

Le 13/06/01 01:49:21, Michael Nachbaur a écrit :
> Here is an example that will illustrate my problem: [...]
> Example 2 (XSL):
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="">
>   <xsl:output method="html"/>
>   <xsl:template match="/">
>     <html><body><img/><br/><a><img/></a></body></html>
>   </xsl:template>
> </xsl:stylesheet>
> Example 2 (Output):
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
> "">
> <html><body>
> <img>
> <br>
> <a><img></a>
> </body></html>

In the XSLT spec, 16.2 HTML Output Method:
  «If the index attribute has the value yes, then the html output method
may add or remove whitespace as it outputs the result tree, so long as it
does not change how an HTML user agent would render the output. The default
value is yes.»

And in the HTML spec, B.3.1 Line Breaks
<> :
  «SGML (see [ISO8879], section 7.6.1) specifies that a line break
immediately following a start tag must be ignored, as must a line break
immediately before an end tag. This applies to all HTML elements without

This means:
is strictly equivalent to
for any conforming user agent, so it isn't a bug of libxslt/libxml.

However, try using indent="no" in your xsl:output element (not tested...)


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