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</link> 

how can i display this link using xslt?

thanks

2 Answers 2

6

How about:

<xsl:template match="link"> <a href="{substring-before(.,',')}"> <xsl:value-of select="substring-after(.,',')"/> </a> </xsl:template> 
Sign up to request clarification or add additional context in comments.

Comments

2

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

3 Comments

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.