RE: inserting HTML comments
This seems to be a problem with the HTML indentation algorithm in your chosen processor. You need to tell us which processor you are using. There's probably not much you can do about it, apart from setting indent="no". You might be able to get away with putting the comment in an otherwise empty <span/> element. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Babos, Andras [mailto:ababos@xxxxxxxxxxxxx] > Sent: 02 November 2004 15:31 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: 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.
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format