RE: [xsl] XSLT: Are XML Comments parseable?

Subject: RE: [xsl] XSLT: Are XML Comments parseable?
From: "Khorasani, Houman" <houman_khorasani@xxxxxxxxxxxxxx>
Date: Wed, 21 Sep 2005 12:41:35 +0100
For some reason I kept thinking very complicated and still couldn't
understand what you guys mean.

But then Jenni Tennison's book about the comments made a "ding" in my
head. :o)

Now I understand; thank you guys very much.

Here is the solution for the archive:

<xsl:template match="/">
	<c><xsl:apply-templates select="comment()"/></c>
</xsl:template>

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


Regards,
Houman


-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: 20 September 2005 16:33
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] XSLT: Are XML Comments parseable?


> I do understand what guys are trying to say, yet it doesn't work.

You have done something rather different to what was suggested.

You no longer have a template matching comment() so when you do
		<xsl:apply-templates select="comment()"/>
the default template will be executed, which in the case of coment nodes
produces no output.

Then you generate a c element node and do
			<xsl:value-of select="."/>

. here is / ie the whole document, and value-of therefore produces the
string value of the document which is the concatenation of all
characters contained in any element (but not comments).


you want
<c><xsl:apply-templates select="comment()"/></c>

together with a template matching comment that does

<xsl:value-of select="."/>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread