Second Life of a Hungarian SharePoint Geek

October 1, 2010

Creating the customization XSL for your external list

Filed under: BCS, External list, SP 2010 — Tags: , , — Peter Holpar @ 22:30

When you would like to customize the XSL of the external list either using SharePoint Designer 2010 or via deploying your custom XSL from a Visual Studio 2010 solution, it is always useful to know how the raw XML data returned by the BCS looks like.

In this case, you can use the very same technique that was showed us by Patrick:

Custom XSLT for the Search Core Results Web Part

You should inject the following content temporarily to the view (when using SPD) or you customization XSL (in case of VS):

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt2="urn:frontpage:internal">
  2.   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  3.   <xsl:template match="/">
  4.     <xmp>
  5.       <xsl:copy-of select="*"/>
  6.     </xmp>
  7.   </xsl:template>
  8. </xsl:stylesheet>

It will cause the raw XML content to be rendered on the page as shown below in the case of my file system example:

image

And this is the whole content of the XML in my case:

  1. <dsQueryResponse>
  2.   <Rows />
  3. </dsQueryResponse>
  4. <dsQueryResponse ViewStyleID="" BaseViewID="1" TemplateType="600" RowLimit="30">
  5.   <Rows>
  6.     <Row BdcIdentity="__bk08003400a300c5004400160047001600c50045005600d6000700c50035001600d6000700c600560064009600c60056003700c5006400f600c6004600560027001300" Icon="&lt;DIV&gt;&lt;a href='?path=\Folder1'&gt;&lt;img title='Folder1' alt='Folder1' src='http://sp2010/_layouts/images/folder.gif&#039; border='0'/&gt;&lt;/a&gt;&lt;/DIV&gt;" Name="Folder1" Size="0" Size.="0" Created="9/18/2010 9:20 PM" LastModified="9/18/2010 9:31 PM" IsFolder="Yes" />
  7.     <Row BdcIdentity="__bk08003400a300c5004400160047001600c50045005600d6000700c50035001600d6000700c600560064009600c60056003700c5006400f600c6004600560027002300" Icon="&lt;DIV&gt;&lt;a href='?path=\Folder2'&gt;&lt;img title='Folder2' alt='Folder2' src='http://sp2010/_layouts/images/folder.gif&#039; border='0'/&gt;&lt;/a&gt;&lt;/DIV&gt;" Name="Folder2" Size="0" Size.="0" Created="9/18/2010 9:31 PM" LastModified="9/18/2010 10:16 PM" IsFolder="Yes" />
  8.     <Row BdcIdentity="__bk89003400a300c5004400160047001600c50045005600d6000700c50035001600d6000700c600560064009600c60056003700c5004400f60036005700d6005600e6004700e2004600f60036008700" Icon="&lt;DIV&gt;&lt;a href='http://sp2010/_layouts/DownloadExternalData.aspx?EntityNamespace=FileSystem.FileSystemModel&amp;EntityName=FileSystemEntity&amp;LobSystemInstanceName=FileSystemModel&amp;StreamAccessorName=FileAccessor&amp;IsXmlEncodedStreamName=true&amp;ItemId=_BdcId_'&gt;&lt;img title='Document.docx' alt='Document.docx' src='http://sp2010/_layouts/images/icdocx.png&#039; border='0'/&gt;&lt;/a&gt;&lt;/DIV&gt;" Name="Document.docx" Size="12716" Size.="12716" Created="9/18/2010 9:25 PM" LastModified="9/18/2010 9:28 PM" IsFolder="No" />
  9.     <Row BdcIdentity="__bk09003400a300c5004400160047001600c50045005600d6000700c50035001600d6000700c600560064009600c60056003700c50044002700160077009600e6007600e2002600d6000700" Icon="&lt;DIV&gt;&lt;a href='http://sp2010/_layouts/DownloadExternalData.aspx?EntityNamespace=FileSystem.FileSystemModel&amp;EntityName=FileSystemEntity&amp;LobSystemInstanceName=FileSystemModel&amp;StreamAccessorName=FileAccessor&amp;IsXmlEncodedStreamName=true&amp;ItemId=_BdcId_'&gt;&lt;img title='Drawing.bmp' alt='Drawing.bmp' src='http://sp2010/_layouts/images/icbmp.gif&#039; border='0'/&gt;&lt;/a&gt;&lt;/DIV&gt;" Name="Drawing.bmp" Size="1282806" Size.="1282806" Created="9/18/2010 9:21 PM" LastModified="9/18/2010 9:30 PM" IsFolder="No" />
  10.     <Row BdcIdentity="__bkc9003400a300c5004400160047001600c50045005600d6000700c50035001600d6000700c600560064009600c60056003700c5007500f6002700b60037008600560056004700e2008700c60037008700" Icon="&lt;DIV&gt;&lt;a href='http://sp2010/_layouts/DownloadExternalData.aspx?EntityNamespace=FileSystem.FileSystemModel&amp;EntityName=FileSystemEntity&amp;LobSystemInstanceName=FileSystemModel&amp;StreamAccessorName=FileAccessor&amp;IsXmlEncodedStreamName=true&amp;ItemId=_BdcId_'&gt;&lt;img title='Worksheet.xlsx' alt='Worksheet.xlsx' src='http://sp2010/_layouts/images/icxlsx.png&#039; border='0'/&gt;&lt;/a&gt;&lt;/DIV&gt;" Name="Worksheet.xlsx" Size="8774" Size.="8774" Created="9/18/2010 9:24 PM" LastModified="9/18/2010 9:27 PM" IsFolder="No" />
  11.   </Rows>
  12. </dsQueryResponse>

You can copy the XML you received in the former step and save it for example into a text file. Then create the XSL that translates the content to the desired format, and replace the original XSL with this new one.

Advertisements

2 Comments »

  1. I have one question here.. why dsQueryResponse apears more then once? im trying to find why it is generating it 2 times here but i cant seem to find the reason.. this tag should apear only one time right?

    http://msdn.microsoft.com/en-us/library/ff754324.aspx

    thxs!

    Comment by Balzaque — October 11, 2010 @ 20:48

    • Hi Balzaque,

      That is really a very good question. I experienced the same. The first (empty) dsQueryResponse seems to be rendered as part of the original page response, the second one seems to be loaded asynchronously, after page load. You should use the second one, that actually contains data.

      I will let you know if I have further info about that.

      Peter

      Comment by Peter Holpar — October 12, 2010 @ 08:15


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: