none
Cant remove tables from XSLTListView webpart output

    Question

  • I've been trying to create a jquery image carousel from an image library but the script doesnt because the XSLTListView webpart wraps my template with tables. Is it possible to remove the tables and just repeat the template I provide. This is what my web part looks like,

    <WebPartPages:XsltListViewWebPart runat="server" IsIncluded="True" GhostedXslLink="main.xsl" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="8" Title="slider" PageType="PAGE_NORMALVIEW" ListName="{557F7470-FDA0-48DA-80B3-B1E1F5C0E24D}" Default="FALSE" DisplayName="slider" __markuptype="vsattributemarkup" __WebPartId="{23071649-EF47-4187-800F-262509F0AAFE}" id="g_23071649_ef47_4187_800f_262509f0aafe" viewcontenttypeid="0x" __designer:customxsl="fldtypes_Ratings.xsl">
        <XmlDefinition>
            <View Name="{B3A72A90-5DAD-4660-9D4B-CCFF0B1FB253}" MobileView="TRUE" Type="HTML" TabularView="FALSE" DisplayName="All Pictures" Url="/slider/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ToolbarTemplate="PictureLibraryViewToolBar" ImageUrl="/_layouts/images/plicon.png">
                <Query/>
                <ViewFields>
                    <FieldRef Name="SelectedFlag"/>
                    <FieldRef Name="DocIcon"/>
                    <FieldRef Name="NameOrTitle"/>
                    <FieldRef Name="ImageSize"/>
                    <FieldRef Name="FileSizeDisplay"/>
                    <FieldRef Name="RequiredField" Explicit="TRUE"/>
                    <FieldRef Name="FileRef" Explicit="TRUE"/>
                </ViewFields>
                <RowLimit Paged="TRUE">30</RowLimit>
                <Toolbar Type="Standard"/>
            </View>
        </XmlDefinition>
        <xsl>
            <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
                <xsl:include href="/_layouts/xsl/main.xsl"/>
                <xsl:param name="AllRows" select="/dsQueryResponse/Rows/Row[$EntityName = '' or (position() &gt;= $FirstRow and position() &lt;= $LastRow)]"/>
                <xsl:param name="dvt_apos">'</xsl:param>
                <xsl:template match="Row" mode="Item">
                    <xsl:param name="thisNode" select="."/>
                    <xsl:param name="class" />
    
                    <div class="cs_article">
                        <a href="#">
                            <img src="{$thisNode/@FileRef}" />
                        </a>
                        <a href="#" class="readmore">Read More</a>
    
                    </div>
                    <!-- End cs_article -->
    
                </xsl:template>
            </xsl:stylesheet>
        </xsl>
        <parameterbindings>
            <ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
            <ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
            <ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
            <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
            <ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" />
            <ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" />
            <ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" />
            <ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" />
            <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
            <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)" />
            <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
            <ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)" />
        </parameterbindings>
    </WebPartPages:XsltListViewWebPart>

    The html inside the template is what I intend to repeat for all the images in the image library.

    Thanks


    ---
    Pre-Sales Consultant (Microsoft Business Intelligence Solutions)
    Tech One Global

    Monday, February 27, 2012 6:10 PM

Answers

  • Hi Raihan,

    I can reproduce your issue in XSLT list view web part, this is because XSLT list view web parts are associated with list views, and list views always display within a table.

    As a workaround, please see a data view web part instead.

    <WebPartPages:DataFormWebPart runat="server" IsIncluded="True" AsyncRefresh="false" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="8" Title="pic1" PageType="PAGE_NORMALVIEW" __markuptype="vsattributemarkup" __WebPartId="{6629D346-E822-4095-8C9A-D2F4916C47E3}" id="g_6629d346_e822_4095_8c9a_d2f4916c47e3" listname="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}" pagesize="10">
    	<DataSources><SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" UseServerDataFormat="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="dataformwebpart1"><SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/><asp:Parameter Name="StartRowIndex" DefaultValue="0"/><asp:Parameter Name="nextpagedata" DefaultValue="0"/><asp:Parameter Name="MaximumRows" DefaultValue="10"/></SelectParameters><DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/></DeleteParameters><UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/></UpdateParameters><InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/></InsertParameters></SharePoint:SPDataSource></DataSources>
    	
    	<datafields>@FileLeafRef,Name (for use in forms);@FSObjType,Item Type;@PreviewExists,Preview Exists;@AlternateThumbnailUrl,Preview Image URL;@File_x0020_Type,File Type;@Title,Title;@ImageWidth,Picture Width;@ImageHeight,Picture Height;@ImageCreateDate,Date Picture Taken;@Description,Description;@Keywords,Keywords;@_x0070_ic1,pic1;@contentt,content type;@a,a;@ID,ID;@ContentType,Content Type;@Created,Created;@Author,Created By;@Modified,Modified;@Editor,Modified By;@_CopySource,Copy Source;@CheckoutUser,Checked Out To;@_CheckinComment,Check In Comment;@CheckedOutTitle,Checked Out To;@CheckedOutUserId,ID of the User who has the item Checked Out;@FileDirRef,Path;@HTML_x0020_File_x0020_Type,HTML File Type;@IsCheckedoutToLocal,Is Checked out to local;@_SourceUrl,Source URL;@_HasCopyDestinations,Has Copy Destinations;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@File_x0020_Size,File Size;@ItemChildCount,Item Child Count;@FolderChildCount,Folder Child Count;@_UIVersionString,Version;@ParentVersionString,Source Version (Converted Document);@ParentLeafName,Source Name (Converted Document);@ThumbnailExists,Thumbnail Exists;</datafields>
    	<XSL><xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
    	<xsl:output method="html" indent="no"/>
    	<xsl:decimal-format NaN=""/>
    		<xsl:param name="dvt_apos">&apos;</xsl:param>
    		<xsl:param name="ManualRefresh"></xsl:param>
    		<xsl:param name="dvt_firstrow">1</xsl:param>
    		<xsl:param name="dvt_nextpagedata" />
    		<xsl:variable name="dvt_1_automode">0</xsl:variable>
    		<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
    			<xsl:choose>
    				<xsl:when test="($ManualRefresh = 'True')">
    				<table width="100%" border="0" cellpadding="0" cellspacing="0">
    					<tr>
    						<td valign="top">
    							<xsl:call-template name="dvt_1"/>
    						</td>
    						<td width="1%" class="ms-vb" valign="top">
    							<img src="/_layouts/images/staticrefresh.gif" id="ManualRefresh" border="0" onclick="javascript: {ddwrt:GenFireServerEvent('__cancel')}" alt="Click here to refresh the dataview."/>
    						</td>
    					</tr>
    				</table>
    			</xsl:when>
    				<xsl:otherwise>
    					<xsl:call-template name="dvt_1"/>
    			</xsl:otherwise>
    			</xsl:choose>
    	</xsl:template>
    		<xsl:template name="dvt_1">
    			<xsl:variable name="dvt_StyleName">Table</xsl:variable>
    			<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
    			<xsl:variable name="dvt_RowCount" select="count($Rows)"/>
    			<xsl:variable name="RowLimit" select="10" />
    			<xsl:variable name="FirstRow" select="$dvt_firstrow" />
    			<xsl:variable name="LastRow" select="$FirstRow + $dvt_RowCount - 1" />
    			<xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
    			<xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>
    			
    				<table border="0" width="100%" cellpadding="2" cellspacing="0">
    					
    					<xsl:call-template name="dvt_1.body">
    						<xsl:with-param name="Rows" select="$Rows"/>
    						<xsl:with-param name="FirstRow" select="1" />
    						<xsl:with-param name="LastRow" select="$LastRow - $FirstRow + 1" />
    					</xsl:call-template>
    				</table>
    			
    			
    		</xsl:template>
    		<xsl:template name="dvt_1.body">
    			<xsl:param name="Rows"/>
    			<xsl:param name="FirstRow" />
    			<xsl:param name="LastRow" />
    			<xsl:for-each select="$Rows">
    		     
                    <div class="cs_article">
                        <a href="#">
                            <img src="{@FileRef}" />
                        </a>
                        <a href="#" class="readmore">Read More</a>
                    </div>
                    <!-- End cs_article -->
               	</xsl:for-each>
    	</xsl:template>
    		
    	</xsl:stylesheet></XSL>
    <parameterbindings>
    		<ParameterBinding Name="ListID" Location="None" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/>
    		<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
    		<ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
    		<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
    		<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
    		<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
    		<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
    		<ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
    	</parameterbindings></WebPartPages:DataFormWebPart>
    Best regards,
    Emir

    Emir Liu

    TechNet Community Support

    Wednesday, February 29, 2012 10:43 AM
  • Hi Raihan,

    We can create a data view web part by clicking Insert tab on SharePoint Designer ribbion > Empty Data View > Click here to select a data source > Select your image library.

    Add your code to dvt_1.body template.

     <xsl:for-each select="$Rows">
        
                   
    <div class="cs_article">
                       
    <a href="#">
                           
    <img src="{@FileRef}" />
                       
    </a>
                       
    <a href="#" class="readmore">Read More</a>
                   
    </div>
                   
    <!-- End cs_article -->
              
    </xsl:for-each>

    Then remove other useless templates and tables from the data view web part.

    Best regards,
    Emir


    Emir Liu

    TechNet Community Support

    Thursday, March 01, 2012 4:49 AM

All replies

  • Hi Raihan,

    I can reproduce your issue in XSLT list view web part, this is because XSLT list view web parts are associated with list views, and list views always display within a table.

    As a workaround, please see a data view web part instead.

    <WebPartPages:DataFormWebPart runat="server" IsIncluded="True" AsyncRefresh="false" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="8" Title="pic1" PageType="PAGE_NORMALVIEW" __markuptype="vsattributemarkup" __WebPartId="{6629D346-E822-4095-8C9A-D2F4916C47E3}" id="g_6629d346_e822_4095_8c9a_d2f4916c47e3" listname="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}" pagesize="10">
    	<DataSources><SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" UseServerDataFormat="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="dataformwebpart1"><SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/><asp:Parameter Name="StartRowIndex" DefaultValue="0"/><asp:Parameter Name="nextpagedata" DefaultValue="0"/><asp:Parameter Name="MaximumRows" DefaultValue="10"/></SelectParameters><DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/></DeleteParameters><UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/></UpdateParameters><InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/></InsertParameters></SharePoint:SPDataSource></DataSources>
    	
    	<datafields>@FileLeafRef,Name (for use in forms);@FSObjType,Item Type;@PreviewExists,Preview Exists;@AlternateThumbnailUrl,Preview Image URL;@File_x0020_Type,File Type;@Title,Title;@ImageWidth,Picture Width;@ImageHeight,Picture Height;@ImageCreateDate,Date Picture Taken;@Description,Description;@Keywords,Keywords;@_x0070_ic1,pic1;@contentt,content type;@a,a;@ID,ID;@ContentType,Content Type;@Created,Created;@Author,Created By;@Modified,Modified;@Editor,Modified By;@_CopySource,Copy Source;@CheckoutUser,Checked Out To;@_CheckinComment,Check In Comment;@CheckedOutTitle,Checked Out To;@CheckedOutUserId,ID of the User who has the item Checked Out;@FileDirRef,Path;@HTML_x0020_File_x0020_Type,HTML File Type;@IsCheckedoutToLocal,Is Checked out to local;@_SourceUrl,Source URL;@_HasCopyDestinations,Has Copy Destinations;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@File_x0020_Size,File Size;@ItemChildCount,Item Child Count;@FolderChildCount,Folder Child Count;@_UIVersionString,Version;@ParentVersionString,Source Version (Converted Document);@ParentLeafName,Source Name (Converted Document);@ThumbnailExists,Thumbnail Exists;</datafields>
    	<XSL><xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
    	<xsl:output method="html" indent="no"/>
    	<xsl:decimal-format NaN=""/>
    		<xsl:param name="dvt_apos">&apos;</xsl:param>
    		<xsl:param name="ManualRefresh"></xsl:param>
    		<xsl:param name="dvt_firstrow">1</xsl:param>
    		<xsl:param name="dvt_nextpagedata" />
    		<xsl:variable name="dvt_1_automode">0</xsl:variable>
    		<xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
    			<xsl:choose>
    				<xsl:when test="($ManualRefresh = 'True')">
    				<table width="100%" border="0" cellpadding="0" cellspacing="0">
    					<tr>
    						<td valign="top">
    							<xsl:call-template name="dvt_1"/>
    						</td>
    						<td width="1%" class="ms-vb" valign="top">
    							<img src="/_layouts/images/staticrefresh.gif" id="ManualRefresh" border="0" onclick="javascript: {ddwrt:GenFireServerEvent('__cancel')}" alt="Click here to refresh the dataview."/>
    						</td>
    					</tr>
    				</table>
    			</xsl:when>
    				<xsl:otherwise>
    					<xsl:call-template name="dvt_1"/>
    			</xsl:otherwise>
    			</xsl:choose>
    	</xsl:template>
    		<xsl:template name="dvt_1">
    			<xsl:variable name="dvt_StyleName">Table</xsl:variable>
    			<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
    			<xsl:variable name="dvt_RowCount" select="count($Rows)"/>
    			<xsl:variable name="RowLimit" select="10" />
    			<xsl:variable name="FirstRow" select="$dvt_firstrow" />
    			<xsl:variable name="LastRow" select="$FirstRow + $dvt_RowCount - 1" />
    			<xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
    			<xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>
    			
    				<table border="0" width="100%" cellpadding="2" cellspacing="0">
    					
    					<xsl:call-template name="dvt_1.body">
    						<xsl:with-param name="Rows" select="$Rows"/>
    						<xsl:with-param name="FirstRow" select="1" />
    						<xsl:with-param name="LastRow" select="$LastRow - $FirstRow + 1" />
    					</xsl:call-template>
    				</table>
    			
    			
    		</xsl:template>
    		<xsl:template name="dvt_1.body">
    			<xsl:param name="Rows"/>
    			<xsl:param name="FirstRow" />
    			<xsl:param name="LastRow" />
    			<xsl:for-each select="$Rows">
    		     
                    <div class="cs_article">
                        <a href="#">
                            <img src="{@FileRef}" />
                        </a>
                        <a href="#" class="readmore">Read More</a>
                    </div>
                    <!-- End cs_article -->
               	</xsl:for-each>
    	</xsl:template>
    		
    	</xsl:stylesheet></XSL>
    <parameterbindings>
    		<ParameterBinding Name="ListID" Location="None" DefaultValue="{0B8FE426-16D0-4350-ADAC-F2D2FB279F29}"/>
    		<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
    		<ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
    		<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
    		<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
    		<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
    		<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
    		<ParameterBinding Name="dvt_nextpagedata" Location="Postback;Connection"/>
    	</parameterbindings></WebPartPages:DataFormWebPart>
    Best regards,
    Emir

    Emir Liu

    TechNet Community Support

    Wednesday, February 29, 2012 10:43 AM
  • Thanks for the reply Emir!

    One thing, I see some tables in your template. Do we need those? How can insert a Data View Web Part in SharePoint Designer 2010 and connect it to my Image Library? I'm sorry for asking such silly questions but I'm very new to SharePoint.

    Thanks


    ---
    Pre-Sales Consultant (Microsoft Business Intelligence Solutions)
    Tech One Global

    Thursday, March 01, 2012 4:05 AM
  • Hi Raihan,

    We can create a data view web part by clicking Insert tab on SharePoint Designer ribbion > Empty Data View > Click here to select a data source > Select your image library.

    Add your code to dvt_1.body template.

     <xsl:for-each select="$Rows">
        
                   
    <div class="cs_article">
                       
    <a href="#">
                           
    <img src="{@FileRef}" />
                       
    </a>
                       
    <a href="#" class="readmore">Read More</a>
                   
    </div>
                   
    <!-- End cs_article -->
              
    </xsl:for-each>

    Then remove other useless templates and tables from the data view web part.

    Best regards,
    Emir


    Emir Liu

    TechNet Community Support

    Thursday, March 01, 2012 4:49 AM
  • Thanks for the prompt response Emir! Will try it out tonight and get back to you!

    ---
    Pre-Sales Consultant (Microsoft Business Intelligence Solutions)
    Tech One Global

    Thursday, March 01, 2012 4:55 AM