Re: [xsl] XSL and js comments (for Google AdSense)

Subject: Re: [xsl] XSL and js comments (for Google AdSense)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 21 Feb 2007 12:02:38 GMT
> What have I missed please?
 you missed comments:-)

 <xsl:template match='*|@*'>
that says to match elements and attributes (but not text, processing
instructions or comments)
so when you do
   <xsl:apply-templates select='node()|@*' />
you get the default templates for text, processing
instructions and comments, which copies text nodes but discards PIs and
comments.

Change
 <xsl:template match='*|@*'>

to
 <xsl:template match='node()|@*'>

Of course the real error is putting the javascript inside a comment in
the first place. In HTML clients the HTML engine still sees the
javascript as the <!-- is not actually a comment marker there , as
script has CDATA content so < is just a normal character, in (real)
XHTML systems thoug script has PCDATA content (as CDATA element type
does not exist in XML) so <!-- is a real comment and so it comments out
the javascript which would then not be passed to the javascript engine.

David

Current Thread