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

Re: template in template? (references)

Subject: Re: template in template? (references)
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Fri, 15 Jun 2001 11:05:10 -0400
thomas templates
[Daniel Bauke]

> yep, i'm still asking stup..erm, simple questions :-)
> well, i'm wondering if it's possible to use sth like following:
>
> <xsl:template match="ref">
>    <link href="@id"> go to ref </link>
> </xsl:template>
>
> <xsl:template match="link">
>    <a href="@href"><xsl:apply-templates/></link>
> </xsl:template>
>

If I can understand what you are looking for (which you haven't made clear
at all), The answer is probably variables.  You cannot write out an element
and then have the stylesheet use it.  But you can select the nodes or values
you are interested in and assign them to one or more variables.  Remember
that once a variable is assigned within an invocation of a template, it
can't be changed.


You can pass these variables to other templates using parameters.  In fact,
you may be able to pass a parameter without having created a varable first.
So your example might go like this:

 <xsl:template match="ref">
     <xsl:call-template name='doLink'>
         <xsl:with-param name='theLink' select='@id'/>
     </xsl:call-template>
 </xsl:template>

 <xsl:template name="doLink">
   <xsl:param name='theLink'/>
    <a href="{$theLink}"><xsl:value-of select='link'/></a>
 </xsl:template>

In this example, you wouldn't really need to use a parameter, but I'm just
showing how to use them.

Tom P


 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.