xsl-list
[Top] [All Lists]

RE: XSLT: Are XML Comments parseable?

2005-09-21 04:41:35
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(_at_)nag(_dot_)co(_dot_)uk] 
Sent: 20 September 2005 16:33
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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
________________________________________________________________________

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



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