Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 30th, 2008, 04:55 AM
requeth@gmail.com
Guest
 
Posts: n/a
Default HTTP links in xml file being displayed in XSLT

I have the following XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="table_classname.xsl"?>
<root>
<classinfo>
<classname>Rhetoric 10</classname>
<classlink>http://webcast.berkeley.edu/course_details.php?
seriesid=1906978535</classlink>
<classrating>"A"</classrating>
<university>"UC Berkeley"</university>
</classinfo>
<classinfo>
<classname>"Physics 10"</classname>
<classlink>http://webcast.berkeley.edu/course_details.php?
seriesid=1906978535</classlink>
<classrating>"A+"</classrating>
<university>"UC Berkeley+"</university>
</classinfo>
</root>

And the following XSLT file:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Class</th>
<th align="left">University</th>
<th align="left">Rating</th>
</tr>
<xsl:for-each select="root/classinfo">
<xsl:sort select="classname"/>
<tr>
<td>
<a><a href="<xsl:value-of select="classlink"/>"><xsl:value-of
select="classname"/></a>
</td>
<td><xsl:value-of select="university"/></td>
<td><xsl:value-of select="classrating"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

I'm trying to get the href link section to pull the classlink
attribute out and the classname attribute out and render it as an HTTP
link. This is throwing an error stating I cant have < in an attribute.
Anyone know how I can get the link to render properly?
  #2  
Old August 30th, 2008, 09:35 AM
Johannes Koch
Guest
 
Posts: n/a
Default Re: HTTP links in xml file being displayed in XSLT

requeth@gmail.com schrieb:
Quote:
<a><a href="<xsl:value-of select="classlink"/>"><xsl:value-of
select="classname"/></a>
[...]
Quote:
I'm trying to get the href link section to pull the classlink
attribute out and the classname attribute out and render it as an HTTP
link. This is throwing an error stating I cant have < in an attribute.
XSLT itself uses XML syntax. So you can't just put tags wherever you
like, and hope that it works.
Quote:
Anyone know how I can get the link to render properly?
Use xsl:attribute or attribute value templates. See the XSLT spec or a
good tutorial for the use of these.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
  #3  
Old August 30th, 2008, 12:25 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: HTTP links in xml file being displayed in XSLT

requeth@gmail.com wrote:
Quote:
<a><a href="<xsl:value-of select="classlink"/>"><xsl:value-of
select="classname"/></a>
Use an attribute value template
<a href="{classlink}">
<xsl:value-of select="classname"/>
</a>

--

Martin Honnen
http://JavaScript.FAQTs.com/
 

Bookmarks

Thread Tools

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles