troubleshooting Question

2 column XSL in "snake" format

Avatar of ckelsoe
ckelsoeFlag for United States of America asked on
Web Languages and StandardsMicrosoft SharePoint
3 Comments1 Solution2140 ViewsLast Modified:
I need help creating XSL to display one field in two columns that snake. For example, if there are 29 rows of data, I want items 1-15 to show up in column 1 and items 16 - 29 in column 2. Below is a page generated by WSS2007 in Sharepoint Designer that alternates the items between the two columns, which is not what I need. I do not know XSL enough to make the necessary modifications.

<%@ Page Language="C#" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<html dir="ltr">

<head runat="server">
<META name="WebPartPageExpansion" content="full">
<meta name="ProgId" content="SharePoint.WebPartPage.Document" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
<meta name="Microsoft Theme" content="Belltown 1011, default">
<style type="text/css">
@import url('ows.css');
</style>
</head>

<body>

<form id="form1" runat="server">
      <WebPartPages:DataFormWebPart runat="server" IsIncluded="True" FrameType="None" NoDefaultStyle="TRUE" ViewFlag="0" Title="" ListName="{F7D98E26-DEE1-42DA-8384-31B59425E5CA}" Default="FALSE" DisplayName="" __markuptype="vsattributemarkup" __WebPartId="{F2E19FA8-0507-4293-BEDA-B173E1116B44}" id="g_f2e19fa8_0507_4293_beda_b173e1116b44" __AllowXSLTEditing="true" WebPart="true" Height="" Width="">
      <DataSources>
            <SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;Query&gt;&lt;OrderBy&gt;&lt;FieldRef Name=&quot;Title&quot; Ascending=&quot;TRUE&quot;/&gt;&lt;/OrderBy&gt;&lt;/Query&gt;&lt;/View&gt;" id="spdatasource2"><SelectParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="F7D98E26-DEE1-42DA-8384-31B59425E5CA"/></SelectParameters><DeleteParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="F7D98E26-DEE1-42DA-8384-31B59425E5CA"/></DeleteParameters><UpdateParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="F7D98E26-DEE1-42DA-8384-31B59425E5CA"/></UpdateParameters><InsertParameters><WebPartPages:DataFormParameter Name="ListID" ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="F7D98E26-DEE1-42DA-8384-31B59425E5CA"/></InsertParameters></SharePoint:SPDataSource>
      </DataSources>
      <ParameterBindings>
            <ParameterBinding Name="ListID" Location="None" DefaultValue="F7D98E26-DEE1-42DA-8384-31B59425E5CA"/>
            <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
            <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
            <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
      </ParameterBindings>
      <datafields>@ID,ID;@ContentType,Content Type;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@Title,Title;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;@URL,URL;@Comments,Notes;</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: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:call-template name="dvt_1"/>
      </xsl:template>
      
      <xsl:template name="dvt_1">
            <xsl:variable name="dvt_StyleName">2ColCma</xsl:variable>
            <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
            <table border="0" width="100%">
                  <tr>
                        <xsl:call-template name="dvt_1.body">
                              <xsl:with-param name="Rows" select="$Rows" />
                        </xsl:call-template>
                  </tr>
            </table>
      </xsl:template>
      <xsl:template name="dvt_1.body">
            <xsl:param name="Rows" />
            <xsl:for-each select="$Rows">
                  <xsl:call-template name="dvt_1.rowview" />
            </xsl:for-each>
      </xsl:template>
      <xsl:template name="dvt_1.rowview">
            <td valign="top" width="50%" class="ms-GRFont" >
                  <b>
                        <a href="{substring-before(@URL, ', ')}">
                              <xsl:value-of select="substring-after(@URL, ', ')" />
                        </a>
                  </b>
                  <br />
                  <xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
                        <br /><span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view" />
                  </xsl:if>
            </td>
            <xsl:if test="position() mod 2 = 0" ddwrt:cf_ignore="1">
                  <xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
                  <xsl:if test="position() != last()" ddwrt:cf_ignore="1">
                        <xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>
                  </xsl:if>
            </xsl:if>
      </xsl:template>
</xsl:stylesheet>      </XSL>
</WebPartPages:DataFormWebPart>
</form>

</body>

</html>
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)
Information Architect
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros