Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 25th, 2005, 11:36 PM
Authorized User
Join Date: Feb 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default HTML formatted text via xsl templates?

In my .xml file, I have a string of text that looks like this:

<description>This is my <a href="http://www.kendietz.com>website</a>.</description>

In my xsl file, I have the following line:

    <xsl:apply-templates select="description" />

and the template is:

    <xsl:template match="description">
            <div id="description"><xsl:apply-templates /></div>

The trouble is, the browser does not display the hyperlink, only the text. What am I doing wrong?

Thanks for any help.

Old February 26th, 2005, 08:04 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Within your description template you didn't ask the stylesheet to output anything, you just told it to apply-templates with no select attribute. This processes all children. If the a element doesn't have specific template then the default template is called which just outputs text, as you discovered.

To fix this you can just add a template that matches the a element:
<xsl:template match="a">
  <xsl:copy-of select="."/>
As you need to output an exact copy of the a element then xsl:copy-of is the easiest option.


Joe (Microsoft MVP - XML)
Old February 26th, 2005, 01:48 PM
Authorized User
Join Date: Feb 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts


Thanks! That worked great. I have to admit, I'm having a really tough time getting a handle on the apply-templates concept. It seems really confusing to me.

Well, maybe this is a step toward figuring it out.

Thanks again!

Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:param and xsl:apply-templates' "select" newbieboobers XSLT 1 March 25th, 2008 07:23 PM
differnce between xsl:apply-templates and xsl:call chandu.mca007 XSLT 2 June 12th, 2007 04:12 AM
HTML formatted mail goes to BadMail. Why? nancy Classic ASP Basics 12 August 24th, 2004 10:19 AM
Sending a CSS formatted HTML mail madhukp Classic ASP Basics 4 June 17th, 2004 11:30 PM
Formatted/HTML text pkgal79 HTML Code Clinic 2 June 18th, 2003 02:18 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.