HTTP links in xml file being displayed in XSLT

Discussion in 'XML' started by requeth@gmail.com, Aug 30, 2008.

  1. Guest

    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?
     
    , Aug 30, 2008
    #1
    1. Advertising

  2. schrieb:
    > <a><a href="<xsl:value-of select="classlink"/>"><xsl:value-of
    > select="classname"/></a>

    [...]
    > 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.

    > 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.)
     
    Johannes Koch, Aug 30, 2008
    #2
    1. Advertising

  3. wrote:

    > <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/
     
    Martin Honnen, Aug 30, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott Allen

    Re: Exception not being displayed

    Scott Allen, Sep 21, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    420
    Scott Allen
    Sep 22, 2004
  2. =?Utf-8?B?TWFydHkgVS4=?=

    Exception not being displayed

    =?Utf-8?B?TWFydHkgVS4=?=, Sep 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    403
    =?Utf-8?B?TWFydHkgVS4=?=
    Sep 21, 2004
  3. jkflens
    Replies:
    2
    Views:
    1,535
    jkflens
    May 30, 2006
  4. boney
    Replies:
    1
    Views:
    592
  5. Andrew Cox

    HTTP Header being displayed at top of HTML

    Andrew Cox, Oct 21, 2003, in forum: ASP General
    Replies:
    1
    Views:
    113
    Jeff Clark
    Oct 21, 2003
Loading...

Share This Page