Searching text elements in XSL and creating a hyperlink

Swobredxejepd

New Member
I need help getting links returned in XML format to display on a website. Currently I'm using\[code\] <xsl:for-each select="Summary/text"> <p> <xsl:value-of select="self::*"/> </p>\[/code\]This grabs each paragraph and indents it properly. This works great, except for links we get. I'm a bit confused on what to do. The text I need displayed as a hyperlink is showing as a separate paragraph like so:\[code\] <a href=http://www.google.com</a>\[/code\]So I thought I'd call a template to do this.\[code\] <xsl:template name="hyperlink"> <xsl:param name="text"/> <xsl:choose> <xsl:when test="contains($text,'href=http://')"> <a> <xsl:attribute name="href"> <xsl:value-of select="substring($text, 8, 500)"/> </xsl:attribute> </a> </xsl:when> <xsl:otherwise> <xsl:value-of select="self::*"/> </xsl:otherwise> </xsl:choose></xsl:template>\[/code\]I don't know if $text or \[code\]'href=http://'\[/code\] is right. When I try to use \[code\]contains('<a href')\[/code\] to test, I get errors. I'd appreciate a nudge in the right direction. I don't think I'm using the correct statements to make this work.
 
Back
Top