XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old October 24th, 2003, 01:33 PM
sfhc sfhc is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: WI
Posts: 32 sfhc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
XSL wont populate XHTML element attrs

Hello,

I know how to use
xsl:value-of to display content in XSL files.

However, I have ran into a problem using xsl:value-of to popluate the value of an XHMTL element attribute.

Such as:
<a href="<xsl:value-of select="foo" />">Click Me</a>

I get a nasty error when doing this.

How can I get this to work?

Thanks

Reply With Quote
  #2  
Old October 29th, 2003, 05:02 AM
hiccup hiccup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 4 hiccup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here is how I do my links

<xsl:template match="link">
<div>
<xsl:attribute name="class">
<xsl:value-of select="local-name()"/>
</xsl:attribute>
<a>
<xsl:attribute name="href">
<xsl:value-of select="url"/>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="abstract"/>
</xsl:attribute>
<xsl:value-of select="title"/> -
<xsl:value-of select="abstract"/>
</a>
</div>
</xsl:template>

example xml data
<link order="3">
<title>Legal stuff</title><abstract>Blah , blah, blah</abstract><url>legal.htm</url>
</link>
<link order="2">
<title>Privacy</title><abstract>Blah , blah, blah</abstract><url>privacy.htm</url>
</link>
<link order="10">
<title>Contact</title><abstract>Blah , blah, blah</abstract><url>contact.htm</url>
</link>

If you are setting several attributes for a tag, then you can also use <xsl:attribute-set> to group them, although its more typing.
Comments on this post
raybiez agrees: Thanks, I needed to know that too

Last edited by hiccup : October 29th, 2003 at 05:05 AM.

Reply With Quote
  #3  
Old October 29th, 2003, 09:36 PM
sfhc sfhc is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: WI
Posts: 32 sfhc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Awesome!

Thanks, that helps so much.

Great reply.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL wont populate XHTML element attrs


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway