[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Understanding named templates and their parameters

Subject: Re: Understanding named templates and their parameters
From: James Clark <jjc@xxxxxxxxxx>
Date: Sun, 25 Apr 1999 07:34:35 +0700
fo insert value as parameter
Michel Goossens wrote:
>
> <xsl:template name="listitem">
>   <xsl:param-variable name="labeltext">labeltext</xsl:param-variable>
>   <xsl:param-variable name="itemid">itemid</xsl:param-variable>
>   <xsl:param-variable name="itemtext">itemtext</xsl:param-variable>
>   <fo:list-item id="{$itemid}">
>     <fo:list-item-label font-style="italic">
>       $labeltext<xsl:text>:</xsl:text>

Character data in a template is copied straight through to the result;
nothing is done with it beyond normal XML parsing. $labeltext is an
expression; you want to put the string value of the expression into the
result.  The way to do that is to use xsl:value-of:

<xsl:value-of select="$labeltext"/>

>     </fo:list-item-label>
>     <fo:list-item-body>
>       <xsl:value-of select="$itemtext"/>
>     </fo:list-item-body>
>   </fo:list-item>
> </xsl:template>
> 
> <xsl:template match='/'>
>  <fo:page-sequence>
>    <xsl:apply-templates/>
>  </fo:page-sequence>
> </xsl:template>
> 
> <xsl:template match="invitation">
> <fo:list-block>
>   <xsl:call-template name="listitem">
>     <xsl:param name="labeltext">To</xsl:param>
>     <xsl:param name="itemid">listto</xsl:param>
>     <xsl:param name="itemtext">to</xsl:param>

This defines the parameter "itemtext" to have a value that's a result
tree fragment containing a single text node with the characters "to". 
Thus when you do <xsl:value-of select="$itemtext"/> you will insert the
characters "to".  What you need is a parameter whose value is a node-set
containing the "to" child of the invitation.  You get that with:

  <xsl:param name="itemtext" expr="to"/>

You could alternatively do:

  <xsl:param name="itemtext"><xsl:value-of select="to"/></xsl:param>

That would give you a parameter that was a result tree fragment
consisting of a text node whose value was the content of the "to" child
of the invitation.

James


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.