Re: Inserting snippets

Subject: Re: Inserting snippets
From: Sebastian Rahtz <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Jan 2000 10:05:22 +0000 (GMT)
Oliver Cope writes:
 > <snippet name="s1">apples</snippet>
 > <snippet name="s2">bananas</snippet>
 > 	. . .
 > <p>
 > 	I like <insert-snippet name="s1" />, but I hate <insert-snippet
 > name="s2" />.
 > </p>
 > 
 > 
 > ...and I'm looking for an XSL transformation that will give me this:
 > '<p>I like apples, but I hate bananas.</p>"
 > 

<xsl:template match="insert-snippet">
 <xsl:value-of select="//snippet[name=current()/@name]"/>
</xsl:template>

though it would be faster to use 

<xsl:template match="insert-snippet">
 <xsl:value-of select="id(@name)/@name"/>
</xsl:template>

if <snippet>'s `name' is declared as of type ID in a DTD.

an
<xsl:template match="snippet"/>

will be needed if you run from the top with an apply-templates

sebastian


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


Current Thread