XSLT - adding attribute of XML element as a link source (href=xsl expression)

Discussion in 'Web Design and Development' started by Spritey, Apr 12, 2008.

  1. Spritey macrumors regular

    Spritey

    Joined:
    Sep 22, 2006
    Location:
    Canada/Norway/USA
    #1
    I'm really stuck on this one part of my XSLT assignment:

    I have an xml document that I need to reproduce as a web page with a left-side navigation bar.

    <left_nav>
    <linktarget link_url="introduction.htm"><![CDATA[Introduction]]></linktarget>
    + several links

    This needs to be somehow converted into a table with one column containing one link per row. I'm trying to do something like this, but I don't know what to do about the " ":

    <table>
    <xsl:for-each select="article/doc/head/left_nav/linktarget">
    <tr>
    <a href="<xsl:value-of select="@link_url"/>"><xsl:value-of select="linktarget"/></a>
    </tr> </xsl:for-each>
    </table>

    I also have the same problem when I try taking the content of an element and put it as meta-description: content ="<value of select="description"/>"

    Never done XSLT or Xpath before so I'm rather confused...
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Not sure which part isn't working for you. I work with XSLT a bit. For the link part use:
    Code:
    <a href="{@link_url}">
    As for the meta tag portion:
    Code:
    <meta name="description">
    <xsl:attribute name="name">
      <xsl:value-of select="description" />
    </xsl:attribute>
    </meta>
    See if that works for you.
     
  3. Spritey thread starter macrumors regular

    Spritey

    Joined:
    Sep 22, 2006
    Location:
    Canada/Norway/USA
    #3
    Seemed to do the trick! Thanks!

    I wasn't sure how to deal with placing information inside "" for an html attribute.

    Now I just gotta figure out how to tackle the rest!
     

Share This Page