In XSLT 1.0, with <xsl:output method="xml" indent="yes">, you are pretty
much at the mercy of the implementation. If you care about whitespace, don't
use indentation.
XSLT 2.0 is stricter, but it still says nothing about this case -
implementations can insert whitespace between a comment node and a start or
end tag, though they are advised against it if the content model is known to
be mixed.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Anderson, Paul [mailto:Paul(_dot_)Anderson(_at_)compuware(_dot_)com]
Sent: 09 October 2007 00:13
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Whitespace around comments
Greetings All,
I'm having some trouble convincing my XSL code to make a
comment an inline structure rather than starting a new line
with the start of the comment. Here is the template doing the work:
<xsl:template name="bold">
<xsl:variable name="content">
<xsl:value-of select="normalize-space(.)"/> </xsl:variable>
<xsl:choose>
<xsl:when test="contains(.,'>')"><menu><xsl:call-template
name="parsemenu"/></menu></xsl:when>
<xsl:when test="$content = 'OK' or $content =
'Cancel'"><gui><xsl:apply-templates/></gui></xsl:when>
<xsl:otherwise><b><xsl:apply-templates/></b><xsl:comment>Comme
nt text here.</xsl:comment></xsl:otherwise>
</xsl:choose>
</xsl:choose>
</xsl:template>
In the output, I'm seeing the following (as an example):
<para>All Probes in the load-sharing setup must be assigned
the same value for <b>Segment Name</b> <!--Comment text
here.-->.</para>
The newline after the </b> tag introduces whitespace between
the bolded word "Name" and the following period. This is a
bad thing. I cannot figure out how the newline is getting in
between the </b> end tag and the start of the comment. The
only thing I can think of is that it is caused by
indent="yes" on the output element for this stylesheet.
Any help is appreciated.
Best regards,
Paul
The contents of this e-mail are intended for the named
addressee only. It contains information that may be
confidential. Unless you are the named addressee or an
authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify
us immediately and then destroy it.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--