[Home] [By Thread] [By Date] [Recent Entries]


You want the attribute value template [1]. Note lines 3 and 7.

 1  <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 2  <xsl:output indent="yes" omit-xml-declaration="yes"/>
 3  <xsl:variable name="tt" select="tocTitle"/>
 4
 5  <xsl:template match="tocTitle">
 6   <tr><td>
 7    <a href="{$tt}">
 8     <xsl:apply-templates />
 9    </a>
10   </td></tr>
11  </xsl:template>
12
13  </xsl:stylesheet>

which when applied to the document below (with Saxon, e.g.):

<tocTitle>tocdoc</tocTitle>

will yield:

<tr>
   <td>
      <a href="tocdoc">tocdoc</a>
   </td>
</tr>

[1] http://www.w3.org/TR/xslt#attribute-value-templates

 -----Original Message-----
> From: Molnar, Chris [mailto:Chris.Molnar@u...]
> Sent: Thursday, May 23, 2002 12:10 PM
> To: 'xml-dev@l...'
> Subject:  xsl escaping
>
>
> I am trying to parse the following xsl into html:
> ---
> <xsl:template match="tocTitle">
> 	<tr><td>
>
> 	<a href="#<xsl:apply-templates select="tocTitle" />">
> 		<xsl:apply-templates />
> 	</a>
>
> 	</td></tr>
> </xsl:template>
> ---
>
> I cannot figure out how to grab the value of tocTitle and reuse it. In a
> nutshell, I have a form that users fill out that creates an html
> page. I am
> allowing them to create an in-page table of contents by entering
> a name for
> each TOC entry. The I want to reuse the text they enter in the final html
> doc in the following three ways:
> 1. as the text of the TOC entry
> 2. as the in-page link (#link)
> 3. as the named anchor the respective link points to
>
> I tried to illustrate this in the non well-formed code above. Any ideas on
> how I could make this work?
>
> Thanks,
> Chris
>
> ____________________________________
> Chris Molnar
> Content Management & Intranet Consulting
> office 773-399-4133
> cell 773-230-7076
>
>
>
>
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
>
> The list archives are at http://lists.xml.org/archives/xml-dev/
>
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
>
>


  • References:
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member