xsl-list
[Top] [All Lists]

RE: inserting HTML comments

2004-11-04 13:13:49
Hi All,

An update on the situation:

I've tried a few different XSL processors to see whether any of them
handles this <PRE> situation correctly. Here's the result:

1. Xalan-C++ 1.8: The whole solution works (all my various templates are
processed as expected) except for this tiny little bug with the <PRE>
tags.

2. Libxslt 1.1.12: Two problems:
  - it inserts newlines into the output as Xalan (as a matter of fact
Libxslt inserts even more...)
  - it simply skips my apply-templates directives (these have a
parameter passed, but AFAIK that's valid)

3. Sablotron 1.0.1: Completely broken. Cannot even pass a Windows path
as an input parameter to the stylesheet. (All the others handled at
least this well.)

4. MSXSL 4.0: Guess what? It works! Surprise... Too bad that I need a
processor which works on Mac OS X also.

5. Saxon: Haven't tried, since it's written in Java and I don't want to
include a JVM in the solution.

It looks like I'll have to contact the Xalan developers, and hope that
they are willing to help me in time.

BTW: AFAICT all my stylesheets are XSLT 1.0 conformant. Is there a tool
to check this?

Regards:
                Andras Babos.


-----Original Message-----
From: Babos, Andras [mailto:ababos(_at_)Graphisoft(_dot_)hu]
Sent: 2004. november 2. 16:31
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] inserting HTML comments

Hi All,

I seem to have a problem with inserting HTML comments in the HTML
output
of an
XSL transformation.

The problem description is as follows:
1. I have an XML file from which I generate the HTML output.
(source.xml)
2. In the XSL file I have a template which contains something like
this:

<PRE>
  <B>
    <xsl:text>some text node </xsl:text>
  </B>
  <xsl:call-template name="insert-anchor">
    <xsl:with-param name="anchor" select="someNode"/>
  </xsl:call-template>
</PRE>

3. and the insert-anchor template looks something like:

<xsl:template name="insert-anchor">
  <xsl:comment> This is a comment </xsl:comment>
  <A>
    <xsl:attribute name="HREF">
      <xsl:value-of select="concat (string (someNode), '.html')"/>
    </xsl:attribute>
    <xsl:value-of select="string (someNode)"/>
  </A>
</xsl:template>

4. I'd expect the output to look like this:

<PRE><B>some text node </B><!-- This is a comment --><A
HREF="value-of-someNode.html">value-of-someNode</A></PRE>

5. but instead I get this:

<PRE>
<B>some text node </B>
<!-- This is a comment -->
<A HREF="value-of-someNode.html">value-of-someNode</A>
</PRE>

6. However, if I don't insert the <B> tags around the text node, I get
this:

<PRE>some text node <!-- This is a comment --><A
HREF="value-of-someNode.html">value-of-someNode</A></PRE>

What I need is the comment placed _right before_ the anchor tag
without
any
kind of whitespace inbetween (and of course no whitespace inserted
into
a <PRE>
tag at all).


Some more background info:
1. I'm using Xalan-C 1.8 with Xerces-C 2.5.0 (Windows).
2. I do have the xsl:output element set to html and indent="yes", but
even if I
turn off the indentation, the problem persists.
3. Of course my original templates are somewhat more comlicated than
these, but
I think the whole problem boils down to the mentioned parts. If you
think it
may help I can post a more detailed template.


Questions:
1. Is this behaviour XSL inherent or XSL processor dependant?
2. If it is the former, then how could I achieve what I'm trying to
do?

TIA:
        Andras Babos.

--+------------------------------------------------------------------
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>
--+--




<Prev in Thread] Current Thread [Next in Thread>