You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by Diwaker Gupta <di...@apache.org> on 2005/08/26 06:42:13 UTC

[views] xsl:comment in templates

I'm writing a template which contains a <script> tag. Often <script> tags are 
enclosed within regular HTML comments (<!-- and -->) to deal with browser 
incompatibilities and so on. I'm trying to achieve this using xsl:comments in 
my templates. However, it seems xsl:comments are completely ignored while 
processing templates. I'm trying this:

<xsl:template name="custom-headers-head">
 <meta name="author" content="Diwaker Gupta"/>
        <xsl:comment>this never shows up</xsl:comment>
</xsl:template>

The <meta> stuff comes out fine, but the xsl:comment is never rendered in the 
HTML output. Any clues?
-- 
Web/Blog/Gallery: http://floatingsun.net

Re: [views] xsl:comment in templates

Posted by Thorsten Scherler <th...@apache.org>.
On Wed, 2005-08-31 at 00:36 -0700, Diwaker Gupta wrote:
> I'm still an XML newbie, so you gotta help me out here Thorsten :-)
> 
> On Friday 26 August 2005 12:57 pm, Thorsten Scherler wrote:
> > http://localhost:8888/prepare.include.xhtml.index
> >
> > still contains them but the stylesheet is <alias:stylesheet/> and the
> > <xsl:comment>. That could be the cause.
> 
> hmm, I don't quite understand. The rest of the tags are still in the xsl: 
> namespace, so why is this a problem?
> 
> > You need to add a stylesheet  in <map:match
> > pattern="get.contract.*.xhtml"> that transforms  <xsl:comment> to
> > <alias:comment>
> 
> Alright, so here's what I did.
> 
> o in the viewHelper.xhtml plugin's output.xmap, I added
> 
> <map:transform src="resources/stylesheets/aliascomment.xsl"/>
> 
> just before the i18n transform.
> 
> o aliascomment.xsl looks like:
> 
>     <xsl:template match="@*|*|text()|processing-instruction()|comment()">
>         <xsl:copy>
>             <xsl:apply-templates select="@*|*|text()|processing-instruction()|
> comment()"/>
>         </xsl:copy>
>     </xsl:template>
>     <xsl:template match="xsl:comment">
>         <alias:comment>
>             <xsl:value-of select="."/>
>         </alias:comment>
>     </xsl:template>
> 
> If I now view http://localhost:8888/prepare.include.xhtml.index, I can see 
> that all xsl:comment elements now appear as alias:comment elements. But the 
> HTML still doesn't comtain the comments. 
> 

It was a shoot in the dark. Sorry! 

> From David's mail, it seems that this problem is not view related? 

Exactly, I was wrong with my assumption. :(

> But I'm not 
> sure. In any case, I'd like to gain a little more understanding of exactly 
> how does this whole "alias" business work, and why does it affect comments in 
> this weird manner. 

Actually I think it does not. I reckon it has more something to do with
the serialization. I guess cocoon change the serializer somehow and now
the comments are gone.

> We don't want to have a hack here, we need to understand 
> the problem first :-)

:)

Agree, but we need to search for the real problem because in the "old
fashion" skin there aren't comments either. I do not think anymore that
this had something to do with the alias vs. xsl namespace.
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: [views] xsl:comment in templates

Posted by Diwaker Gupta <di...@apache.org>.
I'm still an XML newbie, so you gotta help me out here Thorsten :-)

On Friday 26 August 2005 12:57 pm, Thorsten Scherler wrote:
> http://localhost:8888/prepare.include.xhtml.index
>
> still contains them but the stylesheet is <alias:stylesheet/> and the
> <xsl:comment>. That could be the cause.

hmm, I don't quite understand. The rest of the tags are still in the xsl: 
namespace, so why is this a problem?

> You need to add a stylesheet  in <map:match
> pattern="get.contract.*.xhtml"> that transforms  <xsl:comment> to
> <alias:comment>

Alright, so here's what I did.

o in the viewHelper.xhtml plugin's output.xmap, I added

<map:transform src="resources/stylesheets/aliascomment.xsl"/>

just before the i18n transform.

o aliascomment.xsl looks like:

    <xsl:template match="@*|*|text()|processing-instruction()|comment()">
        <xsl:copy>
            <xsl:apply-templates select="@*|*|text()|processing-instruction()|
comment()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="xsl:comment">
        <alias:comment>
            <xsl:value-of select="."/>
        </alias:comment>
    </xsl:template>

If I now view http://localhost:8888/prepare.include.xhtml.index, I can see 
that all xsl:comment elements now appear as alias:comment elements. But the 
HTML still doesn't comtain the comments. 

From David's mail, it seems that this problem is not view related? But I'm not 
sure. In any case, I'd like to gain a little more understanding of exactly 
how does this whole "alias" business work, and why does it affect comments in 
this weird manner. We don't want to have a hack here, we need to understand 
the problem first :-)

-- 
Web/Blog/Gallery: http://floatingsun.net
On Apache: http://people.apache.org/~diwaker

Re: [views] xsl:comment in templates

Posted by Thorsten Scherler <th...@apache.org>.
On Thu, 2005-08-25 at 21:42 -0700, Diwaker Gupta wrote:
> I'm writing a template which contains a <script> tag. Often <script> tags are 
> enclosed within regular HTML comments (<!-- and -->) to deal with browser 
> incompatibilities and so on. I'm trying to achieve this using xsl:comments in 
> my templates. However, it seems xsl:comments are completely ignored while 
> processing templates. I'm trying this:
> 
> <xsl:template name="custom-headers-head">
>  <meta name="author" content="Diwaker Gupta"/>
>         <xsl:comment>this never shows up</xsl:comment>
> </xsl:template>
> 
> The <meta> stuff comes out fine, but the xsl:comment is never rendered in the 
> HTML output. Any clues?

http://localhost:8888/prepare.include.xhtml.index

still contains them but the stylesheet is <alias:stylesheet/> and the
<xsl:comment>. That could be the cause.

You need to add a stylesheet  in <map:match
pattern="get.contract.*.xhtml"> that transforms  <xsl:comment> to
<alias:comment>

HTH

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: [views] xsl:comment in templates

Posted by David Crossley <cr...@apache.org>.
Diwaker Gupta wrote:
> Alright, so I've isolated the bug to 
> skins/common/xslt/html/strip_namespaces.xsl
> 
> Commenting it out brings back the comments.
> 
> A comment in sitemap.xmap says it was introduced due to a bug in Cocoon:
> http://issues.apache.org/bugzilla/show_bug.cgi?id=35348
> 
> I couldn't find any new information on that web page.

That was added as a quick fix just before our last
release to remove extraneous i18n namespaces.

> I haven't played around with i18n, so I don't know what the initial problem 
> was. But presumably we can fix strip_namespaces to leave the comments 
> untouched.
> 
> Now that we know where/why the bug is, hopefully someone can find a smarter 
> way to fix it :-)

It sounds like the "copy-over" is missing the xml comments.
Look at the other stylesheets, some import copy-over.xsl
Some have a explcit default template. Should be easy to fix.

-David

Re: [views] xsl:comment in templates

Posted by Diwaker Gupta <di...@apache.org>.
Alright, so I've isolated the bug to 
skins/common/xslt/html/strip_namespaces.xsl

Commenting it out brings back the comments.

A comment in sitemap.xmap says it was introduced due to a bug in Cocoon:
http://issues.apache.org/bugzilla/show_bug.cgi?id=35348

I couldn't find any new information on that web page.

I haven't played around with i18n, so I don't know what the initial problem 
was. But presumably we can fix strip_namespaces to leave the comments 
untouched.

Now that we know where/why the bug is, hopefully someone can find a smarter 
way to fix it :-)

Diwaker
-- 
Web/Blog/Gallery: http://floatingsun.net
On Apache: http://people.apache.org/~diwaker

Re: [views] xsl:comment in templates

Posted by David Crossley <cr...@apache.org>.
Diwaker Gupta wrote:
> I'm writing a template which contains a <script> tag. Often <script> tags are 
> enclosed within regular HTML comments (<!-- and -->) to deal with browser 
> incompatibilities and so on. I'm trying to achieve this using xsl:comments in 
> my templates. However, it seems xsl:comments are completely ignored while 
> processing templates. I'm trying this:
> 
> <xsl:template name="custom-headers-head">
>  <meta name="author" content="Diwaker Gupta"/>
>         <xsl:comment>this never shows up</xsl:comment>
> </xsl:template>
> 
> The <meta> stuff comes out fine, but the xsl:comment is never rendered in the 
> HTML output. Any clues?

That is one of our serious bugs in the forrest_07 release.
All comments were not coming all the way through to output.
This seemed to happen suddenly in the months leading up to
the release.

http://issues.apache.org/jira/browse/FOR-555
"xml comments are no longer generated or are stripped"

-David