Re: [xsl] working with xsl:comment

Subject: Re: [xsl] working with xsl:comment
From: Rahil <qamar_rahil@xxxxxxxxxxx>
Date: Fri, 24 Jun 2005 12:51:43 +0100
Thanks a lot Andrew.

Its working perfectly!

Rahil

Andrew Welch wrote:



Sorry, another query in quick succession but like earlier I might be missing something rather obvious.

I am writing some information within the <xsl:comment> tags. I want to later retreive this content in another .xsl file. How do I do it? Also can I retrieve the container node of this comment?

E.g <TD width="50%"><FONT SIZE="4" COLOR="red">Checking for existence of 'Wood'...</FONT>
<!--Wood--></TD>


So how do I get the information 'Wood' as well as the position of the containing <TD> so that I can proceed to find other sibling <TD>s from this point?



Use the comment() function eg:


<xsl:template match="comment()">
 <xsl:value-of select="."/>
</xsl:template>

Which will output 'Wood'.  If you want <!--Wood--> then use copy-of
instead of value-of.

To select the TD that contains a comment just use a predicate eg:

<xsl:apply-templates select="TD[comment()]"/>

cheers
andrew

Current Thread