cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <>
Subject Re: [RT] the quest for the perfect template language
Date Fri, 04 Apr 2003 12:17:50 GMT
Pier Fumagalli wrote:
> "Daniel Fagerstrom" <> wrote:
>>With XSLT and agreagate you could write something like:
>><map:match pattern="/news/*">
>> <map:aggregate element="page"/>
>>   <map:part src="cocoon:/data/articles/{1}"/>
>>   <map:part src="cocoon:/data/authors/{request-param:author}/author"/>
>>   <map:part src="cocoon:/data/lists/topnews"/>
>> </map:aggregate>
>> <map:transform src="/templates/news.xslt"/>
>> <map:serialize/>
> No, I can't... You see where do you get the author from? You get it from a
> request parameter. While in my case the author information (or ID) is stored
> in the article original XML data... It would be fair enough if I could
> rewrite it like
> <map:match pattern="/news/*">
>  <map:aggregate element="page"/>
>    <map:part src="cocoon:/data/articles/{1}"/>
>    <map:part 
> src="cocoon:/data/authors/{document(cocoon:/data/articles/{1})/article/autho
> r}"/>
>    <map:part src="cocoon:/data/lists/topnews"/>
>  </map:aggregate>
>  <map:transform src="/templates/news.xslt"/>
>  <map:serialize/>
> </map:match>
> But, darn, that's UGLY! :-(
>     Pier

Ok, I missed that. A new trial:

<map:match pattern="/news/*">
   <map:aggregate element="page"/>
     <map:part src="cocoon:/data/articles/{1}"/>
     <map:part src="cocoon:/data/lists/topnews"/>
   <map:transform src="/templates/news.xslt"/>

<HTML xmlns:xsl="" version="1.0">
     <TITLE><xsl:value-of select="/page/article/title"/></TITLE>
     <H1><xsl:value-of select="/page/article/title"/></H1>
       <xsl:variable name="author" 
       <A href="mailto:{$author/email}">
         <xsl:value-of select="$author/name"/>
     <xsl:copy-of select="/page/article/body"/>
       <DT>Other top news from us</DT>
       <xsl:for-each select="/page/related/articleref">
           <A href="/news/{@id}"><xsl:value-of select="title"/></A>

This is partly pull driven and quite close to your original template, 
and in a non-xml syntax it would of course look a litle bit nicer. If 
you use the document() function with run time dependent data you can 
forget about cashing, but the same applies to your original formulation. 
If you want cashing I'm afraid that you have to do something like what 
you proposed above.

/Daniel Fagerstrom

View raw message