views:

529

answers:

2

I have a list in sharepoint with a hyperlink column.

I'm putting this list into xml and applying xslt to it.

the xml is producing output in the form of:

<link>http://www.foo.com, http://www.foo.com&lt;/link&gt;

how can i display this link using xslt?

thanks

+3  A: 

How about:

<xsl:template match="link">
  <a href="{substring-before(.,',')}">
    <xsl:value-of select="substring-after(.,',')"/>
  </a>
</xsl:template>
Marc Gravell
+2  A: 

For XSLT 2.0

<xsl:template match="link">
    <xsl:element name="a">
      <xsl:attribute name="href">
         <xsl:value-of select="substring-before(.,',')"/>
      </xsl:attribute>
         <xsl:value-of select="substring-after(.,',')"/>
     </xsl:element>
 </xsl:template>

Although it makes it slightly less readable, the extended syntax is considered good practice when stylesheets become large. Literal Result Elements are not as easy to manipulate via XPath as xsl:element/xsl:attribute

Jweede
Does xslt 2.0 not include the abbreviated syntax? (per my post)
Marc Gravell
And should that not be a "match"? (I really haven't looked at 2.0, so I could be very wrong...)
Marc Gravell
Yes. I just pressed the post button a little too late.
Jweede