cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Prevost <prev...@maya.com>
Subject Re: OT: tricky xsl question
Date Thu, 02 Mar 2000 18:48:00 GMT
brian moseley <ix@maz.org> writes:

> hi folks, sorry for the off topic post, but i figure
> somebody on this list must know how to solve this problem.
> 
> my source document contains something like this:
> 
>   <contract>
>     <service name="mail">
>     <service name="calendar">
>   </contract>
> 
> my stylesheet has these definitions:
> 
>   <xsl:variable name="text.mail">Mail</xsl:variable>
>   <xsl:variable name="text.calendar">Calendar</xsl:variable>
> 
> it also has the following template:
> 
>   <xsl:template match="service">
>     <a href=""><xsl:value-of select="@name"/></a><br/>
>   </xsl:template>
> 
> what i really want to get is the value of the text.*
> variable associated with the service, instead of the value
> of the name attribute of the service. ie, 'Calendar' instead
> of 'calendar'. make sense? and no, i don't have the option
> of simply naming the variable 'calendar', instead of
> 'text.calendar'.
> 
> is there a way to dynamically compose an expression? no
> amount of syntactic monkeying has revealed a solution.
> looking through the xslt spec i notice the key function,
> maybe that's actually what i'm looking for, but i'm too dum
> tonight to grok it.

The only method I can think of would be to use the multiple-document
stuff instead:

<xsl:variable name="dummy">
 <text name="mail">Mail</text>
 <text name="calendar">Calendar</text>
</xsl:variable>

Or better, separate this stuff into another file instead of
shoe-horning it into the stylesheet.  (Think of it as a message
catalog file.  :)

Then:

<xsl:template match="service">
 <a href="">
  <xsl:value-of select="document(.)/xsl:variable/text[@name=current()/@name]"/>
 </a>
 <br/>
</xsl:template

If it's a separate document, you could use a simpler path.

John.


Mime
View raw message