Posted By

mustam on 08/29/09


Tagged

stylesheet


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

gelogenic
Tyster


Link URL address of the text's tail in text nodes of xml file


 / Published in: XSLT
 

For foo node, if the node includes URL, link it.

e.g.

before: <foo>bar http://example.com</foo> after: bar <a href="http://example.com">http://example.com</a>

  1. <xsl:template match="foo">
  2. <xsl:choose>
  3. <xsl:when test="contains(., 'http://')">
  4. <xsl:value-of select="substring-before(., 'http://')"/>
  5. <a><xsl:attribute name="href">http://<xsl:value-of select="substring-after(., 'http://')"/></xsl:attribute>http://<xsl:value-of select="substring-after(., 'http://')"/></a>
  6. </xsl:when>
  7. <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
  8. </xsl:choose>
  9. </xsl:template>

Report this snippet  

You need to login to post a comment.