[XML4Lib] XSLT Question

Stephen Graham sgraham at london.edu
Wed Jul 5 10:29:22 EDT 2006


Thanks for the help I have received. I appears that there are two main
ways to do it:

1. 

<xsl:element name="a">
	<xsl:attribute name="href"><xsl:value-of
select="link"/></xsl:attribute> 
</xsl:element>

2. 

<a href="{link}"><xsl:value-of select="title"/></a>

I prefer number two, simply because there is less to it and it's looks
"simpler. I wasn't aware of the {} (curly bracket) syntax. I guess that
it's for only attributes, and that's why if I use {title} instead of
<xsl:value-of select="title"/> it doesn't work?

Stephen

-----Original Message-----
From: xml4lib-bounces at webjunction.org
[mailto:xml4lib-bounces at webjunction.org] On Behalf Of Stephen Graham
Sent: 05 July 2006 13:24
To: xml4lib at webjunction.org
Subject: [XML4Lib] XSLT Question

I am trying to write some XSLT which transforms a RSS feed into XHTML. I
am very nearly there, but I am having problems with one specific aspect.
Te RSS feed is made up of various items like:

<item>
<title>Access to finance: women's enterprise and the role of the
accountant</title>
<link>http://gallifrey.london.edu/cgi-bin/unicrnsrch.pl?type=isbn&amp;va
lue=1859084222</link>
<description>Marlow, Susan; Carter, Sara (2005)</description>
<category>Accounting</category> <pubDate>Wed, 07 Jun 2006 23:00:00
GMT</pubDate> </item>

I am using the XSLT element "<xsl:for-each>", which is looping thought
each item in the feed. I want the value of the link XML/RSS element to
be an actual HREF link for the title element. E.g.

<a href="LINK">TITLE</a>

This is what I currently have:

<xsl:for-each select="item">
	<tr>
       	<td><a href="<xsl:value-of select="link"/>"><xsl:value-of
select="title"/></a></td>
       	<td><xsl:value-of select="description"/></td>
     	</tr>
</xsl:for-each>

This does not work for me, and when I view the RSS feed in the browser
(referencing the XSL syle sheet) I get an error like:

"The character '<' cannot be used in an attribute value. Error
processing resource 'http://unicorn.london.edu/cgi-bin/rss/bo...
<td><a href="<xsl:value-of select="link"/>"><xsl:value-of
select="title"/></a></..."

How do I go about making the title into a HREF using the link element as
the URL? I've tried assigning the value of the link element to a
xsl:param and a xsl:varaible, and then reference that, but I haven't
been successful. Any ideas/help would be appreciated.

Stephen

---------------------------
Stephen Graham
Electronic Library Team
Information Systems Division
London Business School
Regents Park, London NW1 4SA
Tel: +44 (0)20 7000 7000 ext. 4237
Fax: +44 (0)20 7706 1897 

_______________________________________________
XML4Lib mailing list
XML4Lib at webjunction.org
http://lists.webjunction.org/mailman/listinfo/xml4lib

** This email has been scanned by the MessageLabs Email Security System
**

______________________________________________________________________

This email has been scanned by the MessageLabs Email Security System on
behalf of the London Business School community.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________


More information about the XML4Lib mailing list