|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 ![]() |
|
#2
|
|||
|
|||
|
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. Last edited by hiccup : October 29th, 2003 at 05:05 AM. |
|
#3
|
|||
|
|||
|
Awesome!
Thanks, that helps so much.
Great reply. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSL wont populate XHTML element attrs |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|