XSL Stylesheet Not Rendering URL from Multiline Field

Lee Polikoff 21 Reputation points
2022-10-10T12:29:00.427+00:00

I have a SharePoint list that contains a URL field. I use an XSL stylesheet to iterate the list and populate a page with links. I encountered a URL which was longer than 255 characters, which is the limit in SharePoint. I saw this link (hyperlink-columns-does-not-allow-more-than-255.html) and created a multiline column to contain the URL. I modified my XSL stylesheet to use the new field, but it is not working. It is not returning the URL. The name of the multiline field was called LongURL.

Here is the xsl style sheet that works with the URL field:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
    <xsl:output method="html" indent="yes"/>  
    <!-- This template is the "wrapper" or "container" for the custom view. -->  
    <xsl:template match="/">  
        <!-- This is the actual wrapper element that will be emitted -->  
        <div><img src="/sites/abc/Images/Organization_Dashboards.png" border="0" alt="Org"/>  
            <!-- This will tell the data view to look for the actual content  
            and come back when it's done. -->  
            <xsl:apply-templates/>  
        </div>  
        <!-- end wrapper -->  
    </xsl:template>  
    <xsl:template match="/dsQueryResponse/Rows/Row">  
        <!-- This markup is used for each item in the list -->  
       <ul style="list-style-position: outside;padding:0;margin:0"><li style="list-style-type:none;padding:0;margin:0;">  
	   <a href="{@URL}" target="_blank" style="font-size:14px;">  
	   <xsl:value-of select="@URL_x0020_Name" disable-output-escaping="yes"/></a></li></ul>  
  </xsl:template>  
</xsl:stylesheet>  

When I change the a href to @LongURL the main site returns, not where the long url is pointing too.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
    <xsl:output method="html" indent="yes"/>  
    <!-- This template is the "wrapper" or "container" for the custom view. -->  
    <xsl:template match="/">  
        <!-- This is the actual wrapper element that will be emitted -->  
        <div><img src="/sites/abc/Images/Organization_Dashboards.png" border="0" alt="Org"/>  
            <!-- This will tell the data view to look for the actual content  
            and come back when it's done. -->  
            <xsl:apply-templates/>  
        </div>  
        <!-- end wrapper -->  
    </xsl:template>  
    <xsl:template match="/dsQueryResponse/Rows/Row">  
        <!-- This markup is used for each item in the list -->  
       <ul style="list-style-position: outside;padding:0;margin:0"><li style="list-style-type:none;padding:0;margin:0;">  
	   <a href="{@LongURL}" target="_blank" style="font-size:14px;">  
	   <xsl:value-of select="@URL_x0020_Name" disable-output-escaping="yes"/></a></li></ul>  
  </xsl:template>  
</xsl:stylesheet>  

Is there anything I can do to get the Stylesheet to pull the LongURL correctly?

Microsoft 365 and Office SharePoint For business Windows
Microsoft 365 and Office SharePoint Server Development
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2022-10-11T07:40:30.58+00:00

    Hi @Lee Polikoff
    Please try following xsl to rendering Multiline Field

    <xsl:template name="br">  
        <xsl:param name="text"/>  
        <xsl:choose>  
            <xsl:when test="contains($text,'&#xa;')">  
                <xsl:value-of select="substring-before($text,'&#xa;')"/>  
                <br/>  
                <xsl:call-template name="br">  
                    <xsl:with-param name="text">  
                        <xsl:value-of select="substring-after($text,'&#xa;')"/>  
                    </xsl:with-param>  
                </xsl:call-template>  
            </xsl:when>  
            <xsl:otherwise>  
                <xsl:value-of select="$text"/>  
            </xsl:otherwise>  
        </xsl:choose>  
    </xsl:template>  
    <xsl:call-template name="br">  
        <xsl:with-param name="text" select="somenode/mytext"/>  
    </xsl:call-template>  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

  2. Lee Polikoff 21 Reputation points
    2022-10-11T10:36:01.797+00:00

    This xsl stylesheet doesn't include any of the functionality of my xsl stylesheet. How do I implement this with/within MY xsl?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.