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 March 21st, 2007, 11:43 AM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question regarding the display of <a> tags in xml

Hello,

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:

Code:
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:

Code:
<message>
<from>Whiskies Cat Food</from>
<subject>Swarm In Bid Battle!</subject>
<timeSent>20070321113046</timeSent>
<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>
<deleteUrl>index.php?module=myeswarm&amp;action=deleteMessage&amp;messageId=35</deleteUrl>
</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:

Code:
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?
Thanks,
Tim




 
Old March 21st, 2007, 11:54 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





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





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