forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thorsten.scher...@wyona.com>
Subject RE: [jira] Commented: (FOR-834) GenericMarkup strips comments
Date Tue, 18 Apr 2006 14:58:57 GMT
El mar, 18-04-2006 a las 22:08 +0800, Gav.... escribió:
> 
> > -----Original Message-----
> > From: Gavin (JIRA) [mailto:jira@apache.org]
> > Sent: Tuesday, 18 April 2006 8:30 PM
> > To: dev@forrest.apache.org
> > Subject: [jira] Commented: (FOR-834) GenericMarkup strips comments
> > 
> >     [ http://issues.apache.org/jira/browse/FOR-
> > 834?page=comments#action_12374923 ]
> > 
> > Gavin commented on FOR-834:
> > ---------------------------
> > 
> > I have an idea that may cure this but not sure of the 'how'.
> > 
> > What about we create a <comment></comment> element that when processed
by
> > genericMarkup.ft , gets converted into
> > <xsl:comment></xsl:comment>. Then the final output will render correctly
> > into <!-- --> and will work for both comments and SSI commands.?
> > 
> > So in the theme.fv file we could have :-
> > 
> > <forrest:contract name="genericMarkup">
> >             <forrest:property name="genericMarkup">
> > <hr/>
> > <comment>This is a comment</comment>
> >             </forrest:property>
> >     </forrest:contract>
> > 
> > Then we transform this in genericMarkup.ft :-
> > 
> >  <xsl:template match="/">
> >         <forrest:content>
> >           <forrest:part>
> >             <xsl:copy-of select="$genericMarkup/*"/>
> >           </forrest:part>
> >         </forrest:content>
> >       </xsl:template>
> > 
> > Now somewhere above we get it to check for <comment> and transform it into
> > <xsl:comment> , this is the bit I'm stuck on.
> 
> 
> Actually now, I have this working - at least I can get the comments and
> SSI's transformed nicely. I can also then get the rest of the content
> Transformed correctly without repeating the comments.
> 
> Last hurdle, ideas welcome, I can not get the comments and the content
> To mix properly - that is, once I got a comment transformed and then
> The content, any more comments get ignored.
> 
> Using <comment>This is a comment</comment> in the theme.fv file, I then
> Changed the genericMarkup.ft file to read:-
> 
> <xsl:param name="genericMarkup"/>
>       <xsl:template match="/">
>         <forrest:content>
>           <forrest:part>
>  <xsl:copy-of select="$genericMarkup/*[not('comment')]"/>
>  <xsl:comment><xsl:value-of select="$genericMarkup/comment"/></xsl:comment>
>           </forrest:part>
>         </forrest:content>
>       </xsl:template>
>     </xsl:stylesheet>
>   </forrest:template>
> 
> Like I say, comments transform nicely, but any html afterwards and any
> comments afterwards are then ignored. I'm looking at xsl:choose etc
> But no luck so far. Hope the above hints someone else.

Nice Gav, very nice. 

I have ATM no time need to finish a project, so here the quick idea:

Instead of using <xsl:copy-of
select="$genericMarkup/*[not('comment')]"/> ...

do

<xsl:apply-templates select="$genericMarkup/*"/>

and then in templates on their own (!). Replace ... with more
options/matches.

<xsl:templates match="content">
 <xsl:comment><xsl:value-of select="."/></xsl:comment>
</xsl:templates>

<xsl:templates match="*|@*|comment()|...">
 <xsl:copy>
  <xsl:apply-templates select="*|@*|comment()|..."/>
 </xsl:copy>
</xsl:templates>

HTH

Thanks Gavin for your constant and active commitment.

salu2
-- 
Thorsten Scherler
COO Spain
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org


Mime
View raw message