I am totally new to XSL and this is my first time coding it with it. I have HTML and CSS experience and trying to figure out how to integrate it all together for a SharePoint view.

Basically I have an XML file with about 3 records, each having a Title attribute and a URL attibute among others. Now what I want to do is have the Title attribute appear as a URL so when the title is linked, it will navigate to the URL that is specified in the URL attribute. Similar to how <a href="url">Link text</a> works...how would I go about doing this?

So far I have tried:

<a href="'<xsl:value-of select="url"/>'"><xsl:value-of select="title"/></a>

Would I need to accomplish this using an XSL variable? I have this to assign the value to the variable but it does not work:

<xsl:variable name="temp" select="'<xsl:value-of select="url"/>'" />

Any help with this would be much appreciated!!!!! :)

Recommended Answers

All 3 Replies

Alright, I've figured out how to create the variables but how do I create the link? I can't seem to use a href. This is what I was trying:

        <xsl:variable name="titleVar"> 
          <xsl:value-of select="title"/>

        <xsl:variable name="urlVar">
          <xsl:value-of select="link"/>

        <td><a href="$urlVar">"$titleVar"</a></td>

Any idea what I'm doing wrong?

EDIT: I may have figured it out but wont be able to try in SharePoint until next week. Can anyone confirm that this is the right way to do it?

<xsl:variable name="urlVar">
   <xsl:value-of select="link"/>

<td><a href="{$urlVar}"><xsl:value-of select="title"/></a></td>
<xsl:stylesheet version="1.0"
  <xsl:output omit-xml-declaration="yes"/>

  <xsl:variable name ="urlVar"></xsl:variable>
  <xsl:variable name="title"></xsl:variable>

  <xsl:template match="*">
    <xsl:element name="td">
      <xsl:element name="a">
        <xsl:attribute name="href">
          <xsl:value-of select ="$urlVar"/>
        <xsl:value-of select="$title"/>


I've produced what your after using this code. It is worth noting that if you enable Indenting in the stylesheet it wont give the flat look you are after.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.