Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 21st, 2007, 11:43 AM
Registered User
Join Date: Mar 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question regarding the display of <a> tags in xml


I’m new to the group, and fairly new to XSL. I’m using XML version 1.0 and XSL version 1.0. I’m building a site with PHP and I have a message stored in a MySQL database that I’m trying to display to the user. This is what the message looks like in the database:

One of the swarms you have joined called "Whiskies Cat Food" has entered a bid battle.  To view this swarm, click <a href="index.php?module=swarm&amp;action=view&amp;swarmId=1">here</a>.
My xml looks like this:

<from>Whiskies Cat Food</from>
<subject>Swarm In Bid Battle!</subject>
<message><![CDATA[One of the swarms you have joined called "Whiskies Cat Food" has entered a bid battle.  To view this swarm, click <a href="index.php?module=swarm&amp;action=view&amp;swarmId=1">here</a>.]]></message>
Unfortunately the XSL displays it exactly as what’s in the database, and the anchor tags don’t become a link. If I remove the <![CDATA[]]> from the XML the XSL just displays the message as the following and throws out the anchor tags completely:

One of the swarms you have joined called "Whiskies Cat Food" has entered a bid battle.  To view this swarm, click here.
Can you help me to get the anchor tag to display as an actual link that can be clicked on?

Reply With Quote
  #2 (permalink)  
Old March 21st, 2007, 11:54 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

You seem to have two problems. The first is that when you extract the XML from the database, it is being wrapped in CDATA. The purpose of CDATA is to tell the parser that what it contains is character data rather than markup, so you should never wrap XML in a CDATA section if you want to treat it as markup. I don't know how you are extracting the data from MySQL and I don't know MySQL so I can't advise you how to correct this.

Your second problem: you say that when you remove the CDATA tags, the <a> tags are being ignored. This means there is a bug in your stylesheet. You haven't shown us your stylesheet, so I can't help you find the bug. Except that this kind of problem is usually caused by inappropriate use of xsl:value-of rather than xsl:copy-of.

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
<!DOCTYPE> Tags? kennethjaysone HTML Code Clinic 0 May 18th, 2007 01:39 AM
Regular Expression to remove <table> </table> tags mathalete CSS Cascading Style Sheets 2 January 23rd, 2006 01:59 PM
Adding a <p> in text that has no xml tags dzisaacs XSLT 1 November 1st, 2005 02:14 PM
<style> tags in a <body> vs. <div> bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 27th, 2005 08:50 AM
Using <pre> tags in a DataList mpaergk VS.NET 2002/2003 2 November 18th, 2003 01:07 PM

All times are GMT -4. The time now is 01:12 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.