You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Benedikt Heinen <co...@ml.icemark.net> on 2004/12/29 15:57:12 UTC

Cocoon 2.0 -> 2.1 transition question: call-template with nodes (fwd)

[I posted the following message to the cocoon-users list before, but I 
didn't get any answers at all there; maybe one of the developers round 
here knows?]


I'm trying to move from cocoon 2.0 to 2.1, but I am having trouble getting some 
of my old stylesheets to work in 2.1.

Specifically, some of the style sheets passed template methods with nodes being 
passed as parameters - Cocoon 2.1 only seems to pass in the text within the 
nodes, hence further disection of the parameter isn't possible and yields 
"invalid xpath" exceptions.

More specifically, I have a method to pick out a title string for the current 
element to be processed (the "elem" parameter passed into titleStr is an 
element):

         <xsl:call-template name="titleStr">
           <xsl:with-param name="elem" select="title" />
         </xsl:call-template>

The template is defined as such:

 	<xsl:template name="titleStr">
 	  <xsl:param name="elem" />
 	  <xsl:choose>
 	    <xsl:when test="$elem[@lang=$plang]">
 	      <xsl:value-of select="$elem[@lang=$plang]" />
 	    </xsl:when>
 	    <xsl:otherwise>
 	      <xsl:value-of select="$elem" />
 	    </xsl:otherwise>
 	  </xsl:choose>
 	</xsl:template>


[[[ short addition: the input would be triggered during processing of a 
section element, which would look roughly like this:

   <section id="section-ref-01">
     <title lang="de">german section title</title>
     <title lang="en">english section title</title>

     [other content]
   </section>
]]]



I have several named templates in this fashion, this is the easiest one (others 
start making selections to other tags relative to their own; and/or do 
recursive calls). Also, some of these named templates get called several times, 
for different elements during a single stylesheet process, so I wouldn't like 
to duplicate the code into the various places...


Is there a specific reason, that Cocoon 1.8 and Cocoon 2.0 could deal with 
this, and 2.1 doesn't seem to be able to?





   Benedikt

 	INFLUENCE, n.  In politics, a visionary _quo_ given in exchange
 	  for a substantial _quid_.
 			(Ambrose Bierce, The Devil's Dictionary)


Re: Cocoon 2.0 -> 2.1 transition question: call-template with nodes (fwd)

Posted by Sylvain Wallez <sy...@apache.org>.
Benedikt Heinen wrote:

>
> [I posted the following message to the cocoon-users list before, but I 
> didn't get any answers at all there; maybe one of the developers round 
> here knows?]
>
>
> I'm trying to move from cocoon 2.0 to 2.1, but I am having trouble 
> getting some of my old stylesheets to work in 2.1.
>
> Specifically, some of the style sheets passed template methods with 
> nodes being passed as parameters - Cocoon 2.1 only seems to pass in 
> the text within the nodes, hence further disection of the parameter 
> isn't possible and yields "invalid xpath" exceptions.
>
> More specifically, I have a method to pick out a title string for the 
> current element to be processed (the "elem" parameter passed into 
> titleStr is an element):
>
>         <xsl:call-template name="titleStr">
>           <xsl:with-param name="elem" select="title" />
>         </xsl:call-template>
>
> The template is defined as such:
>
>     <xsl:template name="titleStr">
>       <xsl:param name="elem" />
>       <xsl:choose>
>         <xsl:when test="$elem[@lang=$plang]">
>           <xsl:value-of select="$elem[@lang=$plang]" />
>         </xsl:when>
>         <xsl:otherwise>
>           <xsl:value-of select="$elem" />
>         </xsl:otherwise>
>       </xsl:choose>
>     </xsl:template>
>
>
> [[[ short addition: the input would be triggered during processing of 
> a section element, which would look roughly like this:
>
>   <section id="section-ref-01">
>     <title lang="de">german section title</title>
>     <title lang="en">english section title</title>
>
>     [other content]
>   </section>
> ]]]
>
>
>
> I have several named templates in this fashion, this is the easiest 
> one (others start making selections to other tags relative to their 
> own; and/or do recursive calls). Also, some of these named templates 
> get called several times, for different elements during a single 
> stylesheet process, so I wouldn't like to duplicate the code into the 
> various places...
>
>
> Is there a specific reason, that Cocoon 1.8 and Cocoon 2.0 could deal 
> with this, and 2.1 doesn't seem to be able to?


Where does the "$plang" parameter come from? Is it a request parameter? 
If so, you should check that the "use-request-parameters" is properly 
set to true in your transformer's configuration.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }