[xslt] Rogue newline appearing between elements



Hiya,

With xsltproc from libxslt 1.0.6, I'm getting a rogue new line appearing
in my output and I cannot see where it's coming from. If there is something
special in the specification that covers this behaviour, it has elluded
me. I have cut down the stylesheet and data set to about as small as I can
make it whilst retaining some vague sense and still exhibit the oddity.

Command used to process input:
  *xsltproc -o data.html data.xsl data.xml

--8<-------- data/xsl
<?xml version="1.0" standalone="yes"?>

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

<xsl:output method="html" indent="no"/>

<xsl:template match="/">
<html><body><xsl:apply-templates/></body></html>
</xsl:template>

<!-- Content definitions -->
<xsl:template name="section-content-expansion">
<li><a>
     <xsl:value-of select="@title" />
    </a>
    <xsl:if test="subsection or subsubsection or category">
     <ul><xsl:apply-templates /></ul>
    </xsl:if>
</li>
</xsl:template>

<!-- section sections -->
<xsl:template match="section|subsection|subsubsection|category">
<xsl:call-template name="section-content-expansion" />
</xsl:template>

</xsl:stylesheet>
--8<--------

--8<-------- data/xml
<?xml version="1.0"?>
<chapter title="Client Protocol">
<section title="Introduction and Overview" />
<section title="Technical Details">
 <subsection title="Connecting to the server" />
</section>
</chapter>
--8<--------

--8<-------- data/html (the output)
<html><body>
<li><a>Introduction and Overview</a></li>
<li>
<a>Technical Details</a><ul>
 <li><a>Connecting to the server</a></li>
</ul>
</li>
</body></html>
--8<--------

The issue I cannot understand (and this is probably just be my
misunderstanding) is why a newline appears after the <li> for the 'Technical
Details' line. In the stylesheet, the <li> and then <a> are intentionally
immediately next to one another. It is only where the <ul> section is
expanded that this whitespace appears between the <li> and the <a>.

A dump of the output tree with -debug gives me :

--8<--------
*xsltproc -debug data.xsl data.xml
HTML DOCUMENT
standalone=true
  ELEMENT html
    default namespace href=http://www.w3.org/TR/xhtml1/strict
    ELEMENT body
      TEXT
        content=
      ELEMENT li
        ELEMENT a
          TEXT
            content=Introduction and Overview
      TEXT
        content=
      ELEMENT li
        ELEMENT a
          TEXT
            content=Technical Details
        ELEMENT ul
          TEXT
            content=
          ELEMENT li
            ELEMENT a
              TEXT
                content=Connecting to the server
          TEXT
            content=
      TEXT
        content=
--8<--------

Which has no whitespace between the <li> and the <a>. It's magical
whitespace :-)

Please, tell me I'm not going mad and that it's either a bug or I've
misunderstood something; I'd prefer that I'd misunderstood, though.

-- 
Gerph {djf0-.3w6e2w2.226,6q6w2q2,2.3,2m4}
URL: http://www.movspclr.co.uk/
... Eyes to the heavens, screaming at the sky;
    Trying to send you messages, but choking on goodbye.



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