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 August 28th, 2009, 04:56 AM
Authorized User
 
Join Date: Aug 2009
Posts: 31
Thanks: 16
Thanked 1 Time in 1 Post
Default Interpret value as html

Hi,

Code:
<field>
<fieldId>PlanName</fieldId>
<fieldtext>Name of Plan</fieldtext>
<fieldvalue>Battle Plan</fieldvalue>
<fieldvalue2>&lt;b&gt;BATTLE PLAN&lt;b&gt;</fieldvalue2>
<type>NormalField</type>
<sequence>2</sequence>
<stylemarker>1</stylemarker>
</field>
I could select fieldvalue by:

Code:
<td><xsl:value-of select="field/fieldvalue"/><td>
This would be interpreted as: Battle Plan

But what if I want to select fieldvalue2 and interpret it as html?
I want it be like: BATTLE PLAN
I don't want it to be displayed as: <b>BATTLE PLAN</b>

In short, I want to insert the contents and interpret it as html.
Is it possible?

Thank you very much.
 
Old August 28th, 2009, 05:01 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

use <xsl:copy-of> instead of <xsl:value-of>.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
kokoness (August 28th, 2009)
 
Old August 28th, 2009, 05:35 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

If your ouput is html, then definitely

<xsl:value-of
select="field/fieldvalue2" disable-output-escaping="yes"/>

will give the required result BATTLE PLAN when you view the html file.

Check it.
__________________
Rummy
The Following User Says Thank You to mrame For This Useful Post:
kokoness (August 28th, 2009)
 
Old August 28th, 2009, 08:07 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

disable-output-escaping might be appropriate if the HTML markup has for some reason been escaped (ie. written as &lt;b&gt; rather than <b>), but there was no indication that was the case here. If it's literal HTML markup, use xsl:copy-of as suggested by Sam.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
kokoness (August 28th, 2009)
 
Old August 28th, 2009, 04:14 PM
Authorized User
 
Join Date: Aug 2009
Posts: 31
Thanks: 16
Thanked 1 Time in 1 Post
Default

Thanks Sir Sam, Sir Rummy and Sir Michael. I'll try your suggestions later. Thank you very much again. I'm starting to like XSL
 
Old August 30th, 2009, 08:07 PM
Authorized User
 
Join Date: Aug 2009
Posts: 31
Thanks: 16
Thanked 1 Time in 1 Post
Default

Thanks to sir mrame.

disable-output-escaping="yes" did the job.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove orphaned html elements from html string pauliehaha C# 2008 aka C# 3.0 2 June 30th, 2008 09:40 AM
How to interpret checkboxes on server-side forms Ravie PHP How-To 1 June 6th, 2007 05:34 AM
How to interpret checkboxes on server-side forms Ravie Javascript How-To 0 May 24th, 2007 01:10 PM
Can you preload child html files to 1parent html? bekim Javascript How-To 4 January 22nd, 2005 04:17 PM
How to interpret a graphic ? faridahhani BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 June 19th, 2003 04:39 AM





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