Tuesday, October 20, 2009

Using XSL to add a Link to a DataView Webpart populating from XML Web Services

A big problem was trying to display a list from another domain. Dataview Webpart saved me there and my next task was to make the title field link to the document. Since there is no document link readily available, youll have to create it yourself.

First youll need a xsl variable:


<xsl:variable name="webAddy" select="concat('[site]',
substring-before(substring-after(@ows_FileRef,'#'),'Tasks/'),
'Tasks/DispForm.aspx?ID=',@ows_ID)" /> 
 

Pretty simple and straight forward. If your field names don't match, change them accordingly. Next you'll include this:

<a href="{$webAddy}">xsl:value-of select="@ows_LinkTitle"
 /></a>



That just links up the field title to the file name. That's pretty much it. Since you can't use XSL functions within an HTML element, youll have to do both steps to get your link working correctly.