SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having some trouble with URL fields in my List. The problem is that SharePoint stores URLs in two parts, "Description" and "Url", but in SharePoint Designer I can only access the whole URL in the form of <Url>, <Description>. Splitting the string at ', ' is not complicated, but for some reason all Urls containing a ',' are escaped to ',, '.

So my url:,cool.jpg
is rendered as:,, cool.jpg, Description

Is there any elegant way to fix this (tried output escaping, but the ,, still remained) or do I have to go through some tedious xslt transformations?

share|improve this question

Tried using something like this?

 <xsl:value-of select="$MyUrlVal" disable-output-escaping="yes" />
share|improve this answer
Yep, didn't help: <img alt="myimage"> <xsl:attribute name="src"> <xsl:value-of select="@Myimage" disable-output-escaping="yes" /> </xsl:attribute> </img> – Indrek Mar 14 '11 at 8:58

Use the xsl substring-before function, it isn't difficult.

<xsl:value-of select="substring-before(@URL, ', ')"/>
share|improve this answer
But when your value is literally http://server/myimage,,cool.jpg then that won't do much. – James Love Mar 14 '11 at 13:54
That's an input validation issue since that isn't a valid URL to begin with. That should be addressed in a presave action perhaps. – Eric Alexander Mar 14 '11 at 14:03
I just tested the above with a URL with a comma in it and it does work properly. It is looking for everything before comma space and returns that. SO if it were input as,cool.jpg with a description of Why would you do this, it renders as,cool.jpg in my DVWP. – Eric Alexander Mar 14 '11 at 14:08
If I remember correctly, then the double commas were followed by a space and the file names contained multiple commas in different locations. Unfortunately, there's no way to run substring-before() on the last match. I'll check it in the morning. – Indrek Mar 14 '11 at 21:18
up vote 0 down vote accepted

Here's how I got around the problem:
Used a similar XSLT function: and called it:

<xsl:variable name="imgEscapedTemp">
  <xsl:call-template name="string-replace-all">
    <xsl:with-param name="text" select="@Image" />
    <xsl:with-param name="replace" select="',,'" />
    <xsl:with-param name="by" select="'##'" />

<xsl:variable name="imgEscaped">
  <xsl:call-template name="string-replace-all">
    <xsl:with-param name="text" select="substring-before($imgEscapedTemp, ', ')" />
    <xsl:with-param name="replace" select="'##'" />
    <xsl:with-param name="by" select="','" />

<img src="{$imgEscaped}" alt=myImage" />

Logic: replace ',,' with '##', substring before ', ' and then replace '##' with ','

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.