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 June 16th, 2009, 12:03 PM
Registered User
 
Join Date: Jun 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default Displaying XML element in HTML attribute using XSLT

Hi,

I don't know how to display XML element value in HTML attibute using XSLT:

This a fragment of my XML document:

<App>
<videoLink>images/flashplayer.jpg</videoLink>
<videoName>string</videoName>
</App>

This a fragment of my XSLT document:

<div id="flash-panel-right">
<img src="..." border="0" />
</div>

So I want to put the value of videoLink element in src="..." like src="images/flashplayer.jpg"

How can I do that?

Thanks in advance
 
Old June 16th, 2009, 12:27 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It depends what the context node is. Assuming it's the App element, you want

Code:
<img src="{videoLink}" border="0"/>
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old June 16th, 2009, 12:28 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The easiest way is called "Attribute Value Templates".

<img src="{/App/videoLink}" border="0"/>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old June 16th, 2009, 12:30 PM
Registered User
 
Join Date: Jun 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks, I was looking for this answer





Similar Threads
Thread Thread Starter Forum Replies Last Post
need html attribute based on xml attributes charles95621 XSLT 1 May 24th, 2007 05:21 PM
value-of within the HTML element attribute BrendonMelville XSLT 1 March 14th, 2006 11:32 AM
Problem using XSLT to change XML attribute cbeech1980 XSLT 1 October 18th, 2005 06:26 AM
Conditionally displaying html elements in xslt dharni XSLT 1 August 14th, 2005 04:47 PM
Adding an Element with Attribute to XML file xergic Classic ASP XML 0 November 20th, 2004 08:26 AM





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