I have DataView web part that get data from two lists in SharePoint. I'm trying to change web part view but i do not know enough the xsl. my code is
<XSL>
<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:agg="http://schemas.microsoft.com/sharepoint/aggregatesource" 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">'</xsl:param>
<xsl:param name="ManualRefresh"></xsl:param>
<xsl:param name="dvt_firstrow">1</xsl:param>
<xsl:param name="dvt_nextpagedata" />
<xsl:param name="dvt_groupfield" />
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:agg="http://schemas.microsoft.com/sharepoint/aggregatesource" 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[#_x041f__x043e__x0442__x0432__x04 = 'Da']"/>
<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">
<xsl:choose>
<xsl:when test="($FirstRow + $RowLimit - 1) > $dvt_RowCount"><xsl:value-of select="$dvt_RowCount" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$FirstRow + $RowLimit - 1" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
<xsl:variable name="dvt_IsEmpty" select="$dvt_RowCount = 0"/>
<xsl:choose>
<xsl:when test="$dvt_IsEmpty">
<xsl:call-template name="dvt_1.empty"/>
</xsl:when>
<xsl:otherwise>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr >
<th style="width: 261px; text-align:center">Sredstvo koje se izdaje</th>
<th style="width: 164px; text-align:center">Izdata sredstva - trenutno stanje</th>
<th style="width: 240px; text-align:center">Količina - početno stanje</th>
</tr>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
<xsl:with-param name="FirstRow" select="$FirstRow" />
<xsl:with-param name="LastRow" select="$LastRow" />
</xsl:call-template>
</table>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="dvt_1.commandfooter">
<xsl:with-param name="FirstRow" select="$FirstRow" />
<xsl:with-param name="LastRow" select="$LastRow" />
<xsl:with-param name="RowLimit" select="$RowLimit" />
<xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
<xsl:with-param name="RealLastRow" select="number(ddwrt:NameChanged('',-100))" />
</xsl:call-template>
</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"/>
<xsl:param name="FirstRow" />
<xsl:param name="LastRow" />
<xsl:variable name="dvt_Rows"><root>
<xsl:for-each select="$Rows">
<xsl:sort select="#_x0418__x0437__x0434__x0430__x04" order="ascending" />
<xsl:if test="(position() >= $FirstRow and position() <= $LastRow)"><xsl:copy-of select="." /></xsl:if>
</xsl:for-each>
</root></xsl:variable>
<xsl:for-each select="$Rows">
<xsl:sort select="#_x0418__x0437__x0434__x0430__x04" order="ascending" />
<xsl:variable name="NewGroup_0">
<xsl:choose>
<xsl:when test="not ($dvt_groupfield)"><xsl:value-of select="ddwrt:NameChanged(string(#_x0418__x0437__x0434__x0430__x04), 0)" /></xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="0" />
<xsl:when test="not($dvt_groupfield) and (not($NewGroup_0='') and position() >= $FirstRow and position() <= $LastRow or ($FirstRow = position()))">
<xsl:variable name="groupheader0">
<xsl:choose>
<xsl:when test="not (#_x0418__x0437__x0434__x0430__x04) and (#_x0418__x0437__x0434__x0430__x04) != false()"><xsl:value-of select="' '" /></xsl:when>
<xsl:otherwise><xsl:value-of select="#_x0418__x0437__x0434__x0430__x04" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="not ((position()=1) or (position()=$FirstRow))"></xsl:if>
<xsl:call-template name="dvt_1.groupheader0">
<xsl:with-param name="fieldtitle">Sredstvo koje se izdaje</xsl:with-param>
<xsl:with-param name="fieldname">_x0418__x0437__x0434__x0430__x04</xsl:with-param>
<xsl:with-param name="fieldvalue" select="$groupheader0" />
<xsl:with-param name="fieldtype" select="'text'" />
<xsl:with-param name="nodeset" select="msxsl:node-set($dvt_Rows)/root//Row[((#_x0418__x0437__x0434__x0430__x04)=$groupheader0 or ((not(#_x0418__x0437__x0434__x0430__x04) or #_x0418__x0437__x0434__x0430__x04='') and $groupheader0=' '))]" />
<xsl:with-param name="groupid" select="'0'" />
<xsl:with-param name="displaystyle" select="'auto'" />
<xsl:with-param name="imagesrc" select="'/_layouts/images/plus.gif'" />
<xsl:with-param name="alttext" select="'expand'" />
<xsl:with-param name="altname" select="'collapse'" />
<xsl:with-param name="hidedetail" select="true()" />
<xsl:with-param name="showheader" select="true()" />
<xsl:with-param name="showheadercolumn" select="false()" />
</xsl:call-template>
</xsl:when>
</xsl:choose>
<xsl:variable name="BreakOut">
<xsl:choose>
<xsl:when test="not($dvt_groupfield) and position()=$LastRow+1"><xsl:value-of select="ddwrt:NameChanged('', -1)" /></xsl:when>
<xsl:otherwise>BreakOut</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="dvt_KeepItemsTogether" select="false()" />
<xsl:variable name="dvt_HideGroupDetail" select="true()" />
<xsl:if test="(position() >= $FirstRow and position() <= $LastRow) or $dvt_KeepItemsTogether">
<xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
<xsl:call-template name="dvt_1.rowview" />
</xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="0" />
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<xsl:variable name="dvt_GroupStyle" select="'none'" />
<tr style="display:{$dvt_GroupStyle}">
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">ms-alternating</xsl:attribute>
</xsl:if><td class="ms-vb">
<xsl:value-of select="#_x0418__x0437__x0434__x0430__x04" disable-output-escaping="yes" /></td>
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<td class="ms-vb" width="1%" nowrap="nowrap">
<span ddwrt:amkeyfield="" ddwrt:amkeyvalue="string($XPath)" ddwrt:ammode="view"></span>
</td>
</xsl:if><td class="ms-vb">
<xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"> </xsl:text>
</td><td class="ms-vb">
<xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"> </xsl:text>
</td></tr>
</xsl:template>
<xsl:template name="dvt_1.empty">
<xsl:variable name="dvt_ViewEmptyText">There are no items to show in this view.</xsl:variable>
<table border="0" width="100%">
<tr>
<td class="ms-vb">
<xsl:value-of select="$dvt_ViewEmptyText"/>
</td>
</tr>
</table>
</xsl:template>
<xsl:template name="dvt_1.commandfooter">
<xsl:param name="FirstRow" />
<xsl:param name="LastRow" />
<xsl:param name="RowLimit" />
<xsl:param name="dvt_RowCount" />
<xsl:param name="RealLastRow" />
<table cellspacing="0" cellpadding="4" border="0" width="100%">
<tr>
<xsl:if test="$FirstRow > 1 or $LastRow < $dvt_RowCount">
<xsl:call-template name="dvt_1.navigation">
<xsl:with-param name="FirstRow" select="$FirstRow" />
<xsl:with-param name="LastRow" select="$LastRow" />
<xsl:with-param name="RowLimit" select="$RowLimit" />
<xsl:with-param name="dvt_RowCount" select="$dvt_RowCount" />
<xsl:with-param name="RealLastRow" select="$RealLastRow" />
</xsl:call-template>
</xsl:if>
</tr>
</table>
</xsl:template>
<xsl:template name="dvt_1.navigation">
<xsl:param name="FirstRow" />
<xsl:param name="LastRow" />
<xsl:param name="RowLimit" />
<xsl:param name="dvt_RowCount" />
<xsl:param name="RealLastRow" />
<xsl:variable name="PrevRow">
<xsl:choose>
<xsl:when test="$FirstRow - $RowLimit < 1">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$FirstRow - $RowLimit" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="LastRowValue">
<xsl:choose>
<xsl:when test="$LastRow > $RealLastRow">
<xsl:value-of select="$LastRow"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$RealLastRow"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="NextRow">
<xsl:value-of select="$LastRowValue + 1"></xsl:value-of>
</xsl:variable>
<td nowrap="nowrap" class="ms-paging" align="right">
<xsl:if test="$dvt_firstrow > 1" ddwrt:cf_ignore="1">
<a>
<xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent('dvt_firstrow={1}')" />;</xsl:attribute>
Start</a>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<a>
<xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$PrevRow,'}'))" />;</xsl:attribute>
<img src="/_layouts/images/prev.gif" border="0" alt="Previous" />
</a>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:if>
<xsl:value-of select="$FirstRow" />
- <xsl:value-of select="$LastRowValue" />
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"> </xsl:text>
<xsl:if test="$LastRowValue < $dvt_RowCount or string-length($dvt_nextpagedata)!=0" ddwrt:cf_ignore="1">
<a>
<xsl:attribute name="href">javascript: <xsl:value-of select="ddwrt:GenFireServerEvent(concat('dvt_firstrow={',$NextRow,'}'))" />;</xsl:attribute>
<img src="/_layouts/images/next.gif" border="0" alt="Next" />
</a>
</xsl:if>
</td>
</xsl:template>
<xsl:variable name="dvt_2_automode">0</xsl:variable>
<xsl:decimal-format decimal-separator="," grouping-separator="." name="lcid3098" />
<xsl:template name="dvt_1.groupheader0">
<xsl:param name="fieldtitle" />
<xsl:param name="fieldname" />
<xsl:param name="fieldvalue" />
<xsl:param name="fieldtype" />
<xsl:param name="nodeset" />
<xsl:param name="groupid" />
<xsl:param name="displaystyle" />
<xsl:param name="imagesrc" />
<xsl:param name="alttext" />
<xsl:param name="altname" />
<xsl:param name="hidedetail" />
<xsl:param name="showheader" />
<xsl:param name="showheadercolumn" />
<xsl:if test="$showheader" ddwrt:cf_ignore="1">
<tr id="group{$groupid}" style="display:{$displaystyle}">
<td class="ms-gb" colspan="0" style="height: 1px; width: 261px;">
<xsl:if test="not($hidedetail)" ddwrt:cf_ignore="1">
<a href="javascript:" onclick="javascript:ExpGroupBy(this);return false;">
<img src="{$imagesrc}" border="0" alt="{$alttext}" name="{$altname}" /></a>
</xsl:if>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"> </xsl:text>
<xsl:choose>
<xsl:when test="$fieldtype='url'">
<a href="{$fieldvalue}">
<xsl:value-of select="$fieldvalue" />
</a>
</xsl:when>
<xsl:when test="$fieldtype='user'">
<xsl:value-of select="$fieldvalue" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$fieldvalue" disable-output-escaping="yes" /> </xsl:otherwise>
</xsl:choose>
</td>
<td style="height: 1px; width: 164px; text-align:center;"><xsl:value-of disable-output-escaping="yes" select="count($nodeset)" /></td>
<!-- <td style="height: 1px"><xsl:for-each select="/dsQueryResponse/Rows/Row"><xsl:value-of select="#_x041a__x043e__x043b__x0438__x04" disable-output-escaping="yes" /></xsl:for-each></td>
--><td style="height: 1px"><xsl:for-each select="/dsQueryResponse/Rows/Row"><xsl:value-of select="#_x041a__x043e__x043b__x0438__x04" /></xsl:for-each></td>
</tr>
</xsl:if>
</xsl:template>
</xsl:stylesheet> </XSL>
list should look like Figure 1, and I get my results as the code in Figure 2.
So, each field in the column kolicina - pocetno stanje get results for all, should be as in Figure 1 in the column Kolicina
Figure1
Figure2
Related
I am working with Xml that that has multiple levels where I am attempting to display as nested html tables. The Xml may contain one or more levels of information. The current state is the information from the Xml is shown, but has extra empty tables.
Below is the Xml and template I am using. How should I correct the problem?
<?xml version="1.0" encoding="UTF-8"?>
<ErrorRecord>
<Exception>
<ErrorRecord>Exception calling "Fill" with "2" argument(s): "Divide by zero error encountered."</ErrorRecord>
<WasThrownFromThrowStatement>True</WasThrownFromThrowStatement>
<TargetSite>Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)</TargetSite>
<Message>Exception calling "Fill" with "2" argument(s): "Divide by zero error encountered."</Message>
<Data>System.Collections.ListDictionaryInternal</Data>
<InnerException>
<Error>
<Source>Core .Net SqlClient Data Provider</Source>
<Number>8134</Number>
<State>1</State>
<Class>16</Class>
<Server>.</Server>
<Message>Divide by zero error encountered.</Message>
<Procedure></Procedure>
<LineNumber>1</LineNumber>
</Error>
<ClientConnectionId>cdfed373-14fb-4dd7-bebf-7158695cb2c7</ClientConnectionId>
<Class>16</Class>
<LineNumber>1</LineNumber>
<Number>8134</Number>
<Procedure></Procedure>
<Server>.</Server>
<State>1</State>
<Source>Core .Net SqlClient Data Provider</Source>
<IsTransient>False</IsTransient>
<SqlState></SqlState>
<BatchCommand></BatchCommand>
<ErrorCode>-2146232060</ErrorCode>
<TargetSite>Void OnError(System.Data.SqlClient.SqlException, Boolean, System.Action`1[System.Action])</TargetSite>
<Message>Divide by zero error encountered.</Message>
<Data>System.Collections.ListDictionaryInternal</Data>
<InnerException></InnerException>
<HelpLink></HelpLink>
<HResult>-2146232060</HResult>
<StackTrace> at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows)
at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)
at System.Data.SqlClient.SqlDataReader.Read()
at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
at CallSite.Target(Closure, CallSite, Object, Object, Object)</StackTrace>
</InnerException>
<HelpLink></HelpLink>
<Source>System.Management.Automation</Source>
<HResult>-2146233087</HResult>
<StackTrace> at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)</StackTrace>
</Exception>
</ErrorRecord>
<xsl:template match = "ErrorRecord">
<xsl:call-template name="ErrorTable">
<xsl:with-param name="n" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="ErrorTable">
<xsl:param name="n" />
<xsl:for-each select="$n/*">
<table class="ErrorDetailTable">
<tr>
<th class="Property"> </th>
<th class="Value"> </th>
</tr>
<xsl:for-each select="*">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<tr class="tr-even">
<xsl:call-template name="ErrorCells"/>
</tr>
</xsl:when>
<xsl:otherwise>
<tr class="tr-odd">
<xsl:call-template name="ErrorCells"/>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<tr><td colspan="2"> </td></tr>
</table>
</xsl:for-each>
</xsl:template>
<xsl:template name="ErrorCells">
<td class="Property"><xsl:value-of select ="local-name(.)"/></td>
<td class="Value">
<xsl:choose>
<xsl:when test="count(./*) > 0">
<xsl:call-template name="ErrorTable">
<xsl:with-param name="n" select=".." />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="replace_sab">
<xsl:with-param name="s" select="." />
<xsl:with-param name="a" select="'
'" />
<xsl:with-param name="b"><br /></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
<xsl:template name="replace_sab">
<!-- with string s, replace substring a by string b -->
<!-- s, a and b are parameters determined upon calling -->
<xsl:param name="s" />
<xsl:param name="a" />
<xsl:param name="b" />
<xsl:choose>
<xsl:when test="contains($s,$a)">
<xsl:value-of select="substring-before($s,$a)" />
<xsl:copy-of select="$b" />
<xsl:call-template name="replace_sab">
<xsl:with-param name="s" select="substring-after($s,$a)" />
<xsl:with-param name="a" select="$a" />
<xsl:with-param name="b" select="$b" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$s" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
I was able to find the issue, which was due to the reference to the current node with the xml. Solution is as below.
<xsl:template match = "ErrorRecord">
<xsl:call-template name="ErrorTable">
<xsl:with-param name="n" select="./Exception" />
</xsl:call-template>
</xsl:template>
<xsl:template name="ErrorTable">
<xsl:param name="n" />
<xsl:for-each select="$n">
<table class="ErrorDetailTable">
<tr>
<th class="Property"> </th>
<th class="Value"> </th>
</tr>
<xsl:for-each select="*">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">
<tr class="tr-even">
<xsl:call-template name="ErrorCells"/>
</tr>
</xsl:when>
<xsl:otherwise>
<tr class="tr-odd">
<xsl:call-template name="ErrorCells"/>
</tr>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<tr><td colspan="2"> </td></tr>
</table>
</xsl:for-each>
</xsl:template>
<xsl:template name="ErrorCells">
<td class="Property"><xsl:value-of select ="local-name(.)"/></td>
<td class="Value">
<xsl:choose>
<xsl:when test="count(./*) > 0">
<xsl:call-template name="ErrorTable">
<xsl:with-param name="n" select="." />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="replace_sab">
<xsl:with-param name="s" select="." />
<xsl:with-param name="a" select="'
'" />
<xsl:with-param name="b"><br /></xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
<xsl:template name="replace_sab">
<!-- with string s, replace substring a by string b -->
<!-- s, a and b are parameters determined upon calling -->
<xsl:param name="s" />
<xsl:param name="a" />
<xsl:param name="b" />
<xsl:choose>
<xsl:when test="contains($s,$a)">
<xsl:value-of select="substring-before($s,$a)" />
<xsl:copy-of select="$b" />
<xsl:call-template name="replace_sab">
<xsl:with-param name="s" select="substring-after($s,$a)" />
<xsl:with-param name="a" select="$a" />
<xsl:with-param name="b" select="$b" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$s" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Screenshot of tool
I have the following code that was written by another developer. I have taken it as far as I can since I am not versed in XSLT.
Currently the math is set to just do a percentage of just those that have marked themselves P (Present). I want the percentage to count everything but NR (not reported), or just do a math equation where it counts the NR percentage and subtracts it from 100% - either way will work.
Woolf CTR Sonia E
4:47 PM (21 minutes ago)
to me
<xsl:output method="html" indent="no"/>
<xsl:decimal-format NaN=""/>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:param name="dvt_groupfield" />
<xsl:param name="ListName">Morning Report</xsl:param>
<xsl:param name="Day" />
<xsl:param name="Monday">=(2-WEEKDAY(Today)+(Today))</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">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
<xsl:variable name="dvt_RowCount" select="count($Rows)" />
<xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />
<table border="0" width="100%" cellpadding="2" cellspacing="0">
<tr valign="top">
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<th class="ms-vh" width="1%" nowrap="nowrap"></th>
</xsl:if>
<th class="ms-vh" nowrap="" style="width: 129px">Name</th>
<xsl:call-template name="table_header_query">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template></tr>
<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="$dvt_RowCount" />
</xsl:call-template>
<xsl:call-template name="dvt_1.footer">
<xsl:with-param name="Rows" select="$Rows" />
</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:variable name="dvt_Rows"><root>
<xsl:for-each select="$Rows">
<xsl:if test="(position() >= $FirstRow and position() <= $LastRow)"><xsl:copy-of select="." /></xsl:if>
</xsl:for-each>
</root></xsl:variable>
<xsl:for-each select="$Rows">
<xsl:variable name="NewGroup_0">
<xsl:choose>
<xsl:when test="not ($dvt_groupfield)"><xsl:value-of select="ddwrt:NameChanged(string(#PdM), 0)" /></xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="0" />
<xsl:when test="not($dvt_groupfield) and (not($NewGroup_0='') and position() >= $FirstRow and position() <= $LastRow or ($FirstRow = position()))">
<xsl:variable name="groupheader0">
<xsl:choose>
<xsl:when test="not (#PdM) and (#PdM) != false()"><xsl:value-of select="' '" /></xsl:when>
<xsl:otherwise><xsl:value-of select="#PdM" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="groupfooter0">
<xsl:choose>
<xsl:when test="$NewGroup_0=''"><xsl:value-of select="#PdM" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$NewGroup_0" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="not ((position()=1) or (position()=$FirstRow))">
<xsl:call-template name="dvt_1.groupfooter0">
<xsl:with-param name="fieldtitle">Org</xsl:with-param>
<xsl:with-param name="fieldname">PdM</xsl:with-param>
<xsl:with-param name="fieldvalue" select="$groupfooter0" />
<xsl:with-param name="fieldtype" select="''" />
<xsl:with-param name="nodeset" select="msxsl:node-set($dvt_Rows)/root//Row[((#PdM)=$groupfooter0 or ((not(#PdM) or #PdM='') and $groupfooter0=' '))]" />
<xsl:with-param name="groupid" select="'0'" />
<xsl:with-param name="displaystyle" select="'auto'" />
<xsl:with-param name="showfooter" select="true()" />
<xsl:with-param name="showfootercolumn" select="false()" />
</xsl:call-template>
</xsl:if>
<xsl:call-template name="dvt_1.groupheader0">
<xsl:with-param name="fieldtitle">Org</xsl:with-param>
<xsl:with-param name="fieldname">PdM</xsl:with-param>
<xsl:with-param name="fieldvalue" select="$groupheader0" />
<xsl:with-param name="fieldtype" select="''" />
<xsl:with-param name="nodeset" select="msxsl:node-set($dvt_Rows)/root//Row[((#PdM)=$groupheader0 or ((not(#PdM) or #PdM='') and $groupheader0=' '))]" />
<xsl:with-param name="groupid" select="'0'" />
<xsl:with-param name="displaystyle" select="'auto'" />
<xsl:with-param name="imagesrc" select="'/_layouts/images/plus.gif'" />
<xsl:with-param name="alttext" select="'expand'" />
<xsl:with-param name="altname" select="'collapse'" />
<xsl:with-param name="hidedetail" select="false()" />
<xsl:with-param name="showheader" select="true()" />
<xsl:with-param name="showheadercolumn" select="false()" />
</xsl:call-template>
</xsl:when>
</xsl:choose>
<xsl:variable name="BreakOut">
<xsl:choose>
<xsl:when test="not($dvt_groupfield) and position()=$LastRow+1"><xsl:value-of select="ddwrt:NameChanged('', -1)" /></xsl:when>
<xsl:otherwise>BreakOut</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="dvt_KeepItemsTogether" select="false()" />
<xsl:variable name="dvt_HideGroupDetail" select="false()" />
<xsl:if test="(position() >= $FirstRow and position() <= $LastRow) or $dvt_KeepItemsTogether">
<xsl:if test="not($dvt_HideGroupDetail)" ddwrt:cf_ignore="1">
<xsl:call-template name="dvt_1.rowview" />
</xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="0" />
<xsl:when test="($NewGroup_0 or true()) and not($dvt_groupfield)">
<xsl:variable name="groupfooter0">
<xsl:choose>
<xsl:when test="position() = count($Rows) and ($LastRow >= position() or $dvt_KeepItemsTogether) or not($NewGroup_0) or $NewGroup_0=''"><xsl:value-of select="#PdM" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$NewGroup_0" /></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="(position() = count($Rows) and ($LastRow=position() or $dvt_KeepItemsTogether)) or (not($dvt_KeepItemsTogether) and position() > $LastRow and not($BreakOut='BreakOut')) or (not($dvt_KeepItemsTogether) and position() = $LastRow+1) or (position()=last() and $LastRow > last())">
<xsl:call-template name="dvt_1.groupfooter0">
<xsl:with-param name="fieldtitle">Org</xsl:with-param>
<xsl:with-param name="fieldname">PdM</xsl:with-param>
<xsl:with-param name="fieldvalue" select="$groupfooter0" />
<xsl:with-param name="fieldtype" select="''" />
<xsl:with-param name="nodeset" select="msxsl:node-set($dvt_Rows)/root//Row[((#PdM)=$groupfooter0 or ((not(#PdM) or #PdM='') and $groupfooter0=' '))]" />
<xsl:with-param name="groupid" select="'0'" />
<xsl:with-param name="displaystyle" select="'auto'" />
<xsl:with-param name="showfooter" select="true()" />
<xsl:with-param name="showfootercolumn" select="false()" />
</xsl:call-template>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="dvt_1.rowview">
<xsl:variable name="dvt_GroupStyle" select="'none'" />
<tr style="display:{$dvt_GroupStyle}">
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">ms-alternating</xsl:attribute>
</xsl:if>
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
<td class="ms-vb" width="1%" nowrap="nowrap">
<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(#ID))" ddwrt:ammode="view"></span>
</td>
</xsl:if>
<xsl:variable name="monLoc" select="#Mon_x005F_x0020_Location"/>
<xsl:variable name="tuesLoc" select="#Tues_x005F_x0020_Location"/>
<xsl:variable name="wedLoc" select="#Wed_x005F_x0020_Location"/>
<xsl:variable name="thursLoc" select="#Thurs_x005F_x0020_Location"/>
<xsl:variable name="friLoc" select="#Fri_x005F_x0020_Location"/>
<xsl:variable name="listLocation" select="string-length(substring-before(#FileRef, 'sites'))"/>
<xsl:variable name="locationStripped">
<xsl:call-template name="SubstringBeforeLast">
<xsl:with-param name="String" select="#FileRef"/>
<xsl:with-param name="Char" select="'/'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="editURL" select="concat('/', substring($locationStripped, $listLocation+1), '/EditForm.aspx?ID=', #ID)"/>
<td class="ms-vb">
<a href="{$editURL}"
onclick="GoToLink(this);return false;"
target="_self">
<xsl:value-of select="substring-after(#UserName, ';#')" disable-output-escaping="yes"/>
</a>
</td><td class="ms-vb" title="{$monLoc}"><xsl:call-template name="color_reported">
<xsl:with-param name="status"><xsl:value-of select="#Mon_x005F_x0020_Status" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="#Mon_x005F_x0020_Status" /></td><td class="ms-vb" title="{$tuesLoc}"><xsl:call-template name="color_reported">
<xsl:with-param name="status"><xsl:value-of select="#Tues_x005F_x0020_Status" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="#Tues_x005F_x0020_Status" /></td><td class="ms-vb" title="{$wedLoc}"><xsl:call-template name="color_reported">
<xsl:with-param name="status"><xsl:value-of select="#Wed_x005F_x0020_Status" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="#Wed_x005F_x0020_Status" /></td><td class="ms-vb" title="{$thursLoc}"><xsl:call-template name="color_reported">
<xsl:with-param name="status"><xsl:value-of select="#Thurs_x005F_x0020_Status" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="#Thurs_x005F_x0020_Status" /></td><td class="ms-vb" title="{$friLoc}"><xsl:call-template name="color_reported">
<xsl:with-param name="status"><xsl:value-of select="#Fri_x005F_x0020_Status" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="#Fri_x005F_x0020_Status" /></td>
</tr>
</xsl:template>
<xsl:template name="dvt_1.groupheader0">
<xsl:param name="fieldtitle" />
<xsl:param name="fieldname" />
<xsl:param name="fieldvalue" />
<xsl:param name="fieldtype" />
<xsl:param name="nodeset" />
<xsl:param name="groupid" />
<xsl:param name="displaystyle" />
<xsl:param name="imagesrc" />
<xsl:param name="alttext" />
<xsl:param name="altname" />
<xsl:param name="hidedetail" />
<xsl:param name="showheader" />
<xsl:param name="showheadercolumn" />
<xsl:if test="$showheader" ddwrt:cf_ignore="1">
<tr id="group{$groupid}" style="display:{$displaystyle}">
<td class="ms-gb" style="background:#cccccc;" colspan="8">
<xsl:choose>
<xsl:when test="$groupid='0' or $groupid='9'">
<xsl:text></xsl:text>
</xsl:when>
<xsl:when test="$groupid='1'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
<xsl:when test="$groupid='2'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
<xsl:when test="$groupid='3'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
<xsl:when test="$groupid='4'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
<xsl:when test="$groupid='5'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
<xsl:when test="$groupid='6'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
</xsl:choose>
<xsl:if test="not($hidedetail)" ddwrt:cf_ignore="1">
<a href="javascript:" onclick="javascript:ExpGroupBy(this);return false;">
<img src="{$imagesrc}" border="0" alt="{$alttext}" name="{$altname}" /></a>
</xsl:if>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"> </xsl:text>
<xsl:if test="$fieldvalue!='PMO'">
<b>
<xsl:value-of select="$fieldtitle" />
</b>
<xsl:if test="$fieldtitle">: </xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="$fieldtype='url'">
<a href="{$fieldvalue}">
<xsl:value-of select="$fieldvalue" />
</a>
</xsl:when>
<xsl:when test="$fieldtype='user'">
<xsl:value-of select="$fieldvalue" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$fieldvalue" />
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template name="dvt_1.groupfooter0">
<xsl:param name="fieldtitle" />
<xsl:param name="fieldname" />
<xsl:param name="fieldvalue" />
<xsl:param name="fieldtype" />
<xsl:param name="nodeset" />
<xsl:param name="groupid" />
<xsl:param name="displaystyle" />
<xsl:param name="showfooter" />
<xsl:param name="showfootercolumn" />
<xsl:if test="$showfooter" ddwrt:cf_ignore="1">
<tr id="group{$groupid}" style="display:{$displaystyle}">
<td class="ms-gb" style="background:#cccccc;" colspan="1" align="right">
<xsl:choose>
<xsl:when test="$groupid='0' or $groupid='9'"></xsl:when>
<xsl:when test="$groupid='1'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
<xsl:when test="$groupid='2'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes"> </xsl:text>
</xsl:otherwise>
</xsl:choose>
<b><u>%Reported</u>
</b>
</td>
<td class="ms-gb">
<xsl:call-template name="color_present">
<xsl:with-param name="present"><xsl:value-of select="count($nodeset[#Mon_x005F_x0020_Status!='NR']) div count($nodeset)" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="format-number(count($nodeset[#Mon_x005F_x0020_Status!='NR']) div count($nodeset), '0%')" /></td>
<td class="ms-gb">
<xsl:call-template name="color_present">
<xsl:with-param name="present"><xsl:value-of select="count($nodeset[#Tues_x005F_x0020_Status!='NR']) div count($nodeset)" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="format-number(count($nodeset[#Tues_x005F_x0020_Status!='NR']) div count($nodeset), '0%')" /></td>
<td class="ms-gb">
<xsl:call-template name="color_present">
<xsl:with-param name="present"><xsl:value-of select="count($nodeset[#Wed_x005F_x0020_Status!='NR']) div count($nodeset)" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="format-number(count($nodeset[#Wed_x005F_x0020_Status!='NR']) div count($nodeset), '0%')" /></td>
<td class="ms-gb">
<xsl:call-template name="color_present">
<xsl:with-param name="present"><xsl:value-of select="count($nodeset[#Thurs_x005F_x0020_Status!='NR']) div count($nodeset)" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="format-number(count($nodeset[#Thurs_x005F_x0020_Status!='NR']) div count($nodeset), '0%')" /></td>
<td class="ms-gb">
<xsl:call-template name="color_present">
<xsl:with-param name="present"><xsl:value-of select="count($nodeset[#Fri_x005F_x0020_Status!='NR']) div count($nodeset)" /></xsl:with-param>
</xsl:call-template>
<xsl:value-of select="format-number(count($nodeset[#Fri_x005F_x0020_Status!='NR']) div count($nodeset), '0%')" /></td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template name="dvt_1.footer">
<xsl:param name="Rows" />
<tr >
<td class="ms-vh" style="color:black; width: 129px;" align="right"><b><u>Org Totals</u></b></td>
<td class="ms-vh" colspan="8"></td>
</tr>
<xsl:variable name="presMon" select="count(/dsQueryResponse/Rows/Row[#Mon_x005F_x0020_Status='P'])" />
<xsl:variable name="presTues" select="count(/dsQueryResponse/Rows/Row[#Tues_x005F_x0020_Status='P'])" />
<xsl:variable name="presWed" select="count(/dsQueryResponse/Rows/Row[#Wed_x005F_x0020_Status='P'])" />
<xsl:variable name="presThurs" select="count(/dsQueryResponse/Rows/Row[#Thurs_x005F_x0020_Status='P'])" />
<xsl:variable name="presFri" select="count(/dsQueryResponse/Rows/Row[#Fri_x005F_x0020_Status='P'])" />
<tr >
<td class="ms-vb" align="right" style="width: 129px"><u>O/H</u></td>
<td class="ms-vb"><xsl:value-of select="$presMon" /></td>
<td class="ms-vb"><xsl:value-of select="$presTues" /></td>
<td class="ms-vb"><xsl:value-of select="$presWed" /></td>
<td class="ms-vb" style="width: 13px"><xsl:value-of select="$presThurs" /></td>
<td class="ms-vb"><xsl:value-of select="$presFri" /></td><td class="ms-vb" style="width: 26px">
<xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes"> </xsl:text>
</td></tr>
<xsl:variable name="offMon" select="count(/dsQueryResponse/Rows/Row[#Mon_x005F_x0020_Status='O'])" />
<xsl:variable name="offTues" select="count(/dsQueryResponse/Rows/Row[#Tues_x005F_x0020_Status='O'])" />
<xsl:variable name="offWed" select="count(/dsQueryResponse/Rows/Row[#Wed_x005F_x0020_Status='O'])" />
<xsl:variable name="offThurs" select="count(/dsQueryResponse/Rows/Row[#Thurs_x005F_x0020_Status='O'])" />
<xsl:variable name="offFri" select="count(/dsQueryResponse/Rows/Row[#Fri_x005F_x0020_Status='O'])" />
<xsl:if test="($offMon + $offTues + $offWed + $offThurs + $offFri) != 0">
I have a Content Query Webpart (Not a dataview) which displays a list of articles that were written that day on the home page. I need to be able to group the items by Category, however by default the Categories are Alphabetized A through B instead of by priority (something I can change/edit/update).
I've tried a few different combinations. I am attaching a List of Fields, and I will put the code here.
Please let me know if you need any additional information.
Columns
Title - Single line of text
Creation Date Override - Date and Time
News Source - Single line of text
Original Author - Single line of text
Original Publishing Date - Date and Time
Article Text - Multiple lines of text
Month - Calculated (calculation based on other columns)
Month ID - Calculated (calculation based on other columns)
ISODate - Calculated (calculation based on other columns)
Category - Choice
Group Order - Lookup
Group Order:HomePage Order - Lookup
Created By - Person or Group
Modified By - Person or Group
(I know group order is a terrible name, but I got tired of remaking the list and Category was temporarily being used)
Header.xsl
<xsl:stylesheet
version="1.0"
exclude-result-prefixes="x d xsl msxsl cmswrt"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:template name="DefaultHeader" match="*" mode="header">
<div class="groupheader item medium">
<xsl:call-template name="OuterTemplate.GetGroupName">
<xsl:with-param name="GroupName" select="#*[name()=$Group]"/>
<xsl:with-param name="GroupType" select="$GroupType"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="LargeText" match="*[#GroupStyle='LargeText']" mode="header">
<div class="groupheader item large">
<xsl:call-template name="OuterTemplate.GetGroupName">
<xsl:with-param name="GroupName" select="#Category"/>
<xsl:with-param name="GroupType" select="$GroupType"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="SmallText" match="*[#GroupStyle='SmallText']" mode="header">
<div class="groupheader item small">
<xsl:call-template name="OuterTemplate.GetGroupName">
<xsl:with-param name="GroupName" select="#*[name()=$Group]"/>
<xsl:with-param name="GroupType" select="$GroupType"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="Band" match="*[#GroupStyle='Band']" mode="header">
<div class="groupheader item band">
<xsl:call-template name="OuterTemplate.GetGroupName">
<xsl:with-param name="GroupName" select="#*[name()=$Group]"/>
<xsl:with-param name="GroupType" select="$GroupType"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="Centered" match="*[#GroupStyle='Centered']" mode="header">
<div class="groupheader item centered">
<xsl:call-template name="OuterTemplate.GetGroupName">
<xsl:with-param name="GroupName" select="#*[name()=$Group]"/>
<xsl:with-param name="GroupType" select="$GroupType"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template name="Separator" match="*[#GroupStyle='Separator']" mode="header">
<div class="separator">
</div>
</xsl:template>
<xsl:template name="Whitespace" match="*[#GroupStyle='Whitespace']" mode="header">
<div class="whitespace">
<xsl:text>
</xsl:text>
</div>
</xsl:template>
<xsl:template name="AddCategory" match="*[#GroupStyle='AddCategory']" mode="header">
<div class="whitespace">
<xsl:value-of select="#Category" />
</div>
</xsl:template>
</xsl:stylesheet>
Main.xml
<xsl:stylesheet
version="1.0"
exclude-result-prefixes="x xsl cmswrt cbq"
xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:cmswrt="http://schemas.microsoft.com/WebPart/v3/Publishing/runtime"
xmlns:cbq="urn:schemas-microsoft-com:ContentByQueryWebPart" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="xml" indent="no" media-type="text/html" omit-xml-declaration="yes"/>
<xsl:param name="cbq_isgrouping" />
<xsl:param name="cbq_columnwidth" />
<xsl:param name="Group" />
<xsl:param name="GroupType" />
<xsl:param name="cbq_iseditmode" />
<xsl:param name="cbq_viewemptytext" />
<xsl:param name="cbq_errortext" />
<xsl:param name="SiteId" />
<xsl:param name="WebUrl" />
<xsl:param name="PageId" />
<xsl:param name="WebPartId" />
<xsl:param name="FeedPageUrl" />
<xsl:param name="FeedEnabled" />
<xsl:param name="SiteUrl" />
<xsl:param name="BlankTitle" />
<xsl:param name="BlankGroup" />
<xsl:param name="UseCopyUtil" />
<xsl:param name="DataColumnTypes" />
<xsl:param name="ClientId" />
<xsl:param name="Source" />
<xsl:param name="RootSiteRef" />
<xsl:param name="CBQPageUrl" />
<xsl:param name="CBQPageUrlQueryStringForFilters" />
<xsl:variable name="BeginList" select="string('<ul class="dfwp-list">')" />
<xsl:variable name="EndList" select="string('</ul>')" />
<xsl:variable name="BeginListItem" select="string('<li class="dfwp-item">')" />
<xsl:variable name="EndListItem" select="string('</li>')" />
<xsl:template match="/">
<xsl:call-template name="OuterTemplate" />
</xsl:template>
<xsl:template name="OuterTemplate">
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
<xsl:variable name="RowCount" select="count($Rows)" />
<xsl:variable name="IsEmpty" select="$RowCount = 0" />
<div id="{concat('cbqwp', $ClientId)}" class="cbq-layout-main">
<xsl:if test="$cbq_iseditmode = 'True' and string-length($cbq_errortext) != 0">
<div class="wp-content description">
<xsl:value-of disable-output-escaping="yes" select="$cbq_errortext" />
</div>
</xsl:if>
<xsl:choose>
<xsl:when test="$IsEmpty">
<xsl:call-template name="OuterTemplate.Empty" >
<xsl:with-param name="EditMode" select="$cbq_iseditmode" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="OuterTemplate.Body">
<xsl:with-param name="Rows" select="$Rows" />
<xsl:with-param name="FirstRow" select="1" />
<xsl:with-param name="LastRow" select="$RowCount" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</div>
<xsl:if test="$FeedEnabled = 'True' and $PageId != ''">
<div class="cqfeed">
<xsl:variable name="FeedUrl1" select="concat($SiteUrl,$FeedPageUrl,'xsl=1&web=',$WebUrl,'&page=',$PageId,'&wp=',$WebPartId,'&pageurl=',$CBQPageUrl,$CBQPageUrlQueryStringForFilters)" />
<img src="\_layouts\images\rss.gif" border="0" alt="{cmswrt:GetPublishingResource('CbqRssAlt')}"/>
</div>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.Empty">
<xsl:param name="EditMode" />
<xsl:if test="$EditMode = 'True' and string-length($cbq_errortext) = 0">
<div class="wp-content description">
<xsl:value-of disable-output-escaping="yes" select="$cbq_viewemptytext" />
</div>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.Body">
<xsl:param name="Rows" />
<xsl:param name="FirstRow" />
<xsl:param name="LastRow" />
<xsl:variable name="BeginColumn1" select="string('<ul class="dfwp-column dfwp-list" style="width:')" />
<xsl:variable name="BeginColumn2" select="string('%" >')" />
<xsl:variable name="BeginColumn" select="concat($BeginColumn1, $cbq_columnwidth, $BeginColumn2)" />
<xsl:variable name="EndColumn" select="string('</ul>')" />
<xsl:for-each select="$Rows">
<xsl:variable name="CurPosition" select="position()" />
<xsl:if test="($CurPosition >= $FirstRow and $CurPosition <= $LastRow)">
<xsl:variable name="StartNewGroup" select="#__begingroup = 'True'" />
<xsl:variable name="StartNewColumn" select="#__begincolumn = 'True'" />
<xsl:choose>
<xsl:when test="$cbq_isgrouping != 'True'">
<xsl:if test="$CurPosition = $FirstRow">
<xsl:value-of disable-output-escaping="yes" select="$BeginColumn" />
</xsl:if>
</xsl:when>
<xsl:when test="$StartNewGroup and $StartNewColumn">
<xsl:choose>
<xsl:when test="$CurPosition = $FirstRow">
<xsl:value-of disable-output-escaping="yes" select="$BeginColumn" />
<xsl:call-template name="OuterTemplate.CallHeaderTemplate"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="OuterTemplate.CallFooterTemplate"/>
<xsl:value-of disable-output-escaping="yes" select="concat($EndColumn, $BeginColumn)" />
<xsl:call-template name="OuterTemplate.CallHeaderTemplate"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$StartNewGroup">
<xsl:call-template name="OuterTemplate.CallFooterTemplate"/>
<xsl:call-template name="OuterTemplate.CallHeaderTemplate"/>
</xsl:when>
<xsl:when test="$StartNewColumn">
<xsl:choose>
<xsl:when test="$CurPosition = $FirstRow">
<xsl:value-of disable-output-escaping="yes" select="$BeginColumn" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="concat($EndColumn, $BeginColumn)" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="OuterTemplate.CallItemTemplate">
<xsl:with-param name="CurPosition" select="$CurPosition" />
</xsl:call-template>
<xsl:if test="$CurPosition = $LastRow">
<xsl:if test="$cbq_isgrouping = 'True'">
<xsl:call-template name="OuterTemplate.CallFooterTemplate"/>
</xsl:if>
<xsl:value-of disable-output-escaping="yes" select="$EndColumn" />
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:template>
<xsl:template name="OuterTemplate.CallHeaderTemplate">
<xsl:value-of disable-output-escaping="yes" select="$BeginListItem" />
<xsl:apply-templates select="." mode="header">
</xsl:apply-templates>
<xsl:value-of disable-output-escaping="yes" select="$BeginList" />
</xsl:template>
<xsl:template name="OuterTemplate.CallItemTemplate">
<xsl:param name="CurPosition" />
<xsl:value-of disable-output-escaping="yes" select="$BeginListItem" />
<xsl:choose>
<xsl:when test="#Style='NewsRollUpItem'">
<xsl:apply-templates select="." mode="itemstyle">
<xsl:with-param name="EditMode" select="$cbq_iseditmode" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="#Style='NewsBigItem'">
<xsl:apply-templates select="." mode="itemstyle">
<xsl:with-param name="CurPos" select="$CurPosition" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="#Style='NewsCategoryItem'">
<xsl:apply-templates select="." mode="itemstyle">
<xsl:with-param name="CurPos" select="$CurPosition" />
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="itemstyle">
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
<xsl:value-of disable-output-escaping="yes" select="$EndListItem" />
</xsl:template>
<xsl:template name="OuterTemplate.CallFooterTemplate">
<xsl:value-of disable-output-escaping="yes" select="$EndList" />
<xsl:value-of disable-output-escaping="yes" select="$EndListItem" />
</xsl:template>
<xsl:template name="OuterTemplate.GetSafeLink">
<xsl:param name="UrlColumnName"/>
<xsl:if test="$UseCopyUtil = 'True'">
<xsl:value-of select="concat($RootSiteRef,'/_layouts/CopyUtil.aspx?Use=id&Action=dispform&ItemId=',#ID,'&ListId=',#ListId,'&WebId=',#WebId,'&SiteId=',$SiteId,'&Source=',$Source)"/>
</xsl:if>
<xsl:if test="$UseCopyUtil != 'True'">
<xsl:call-template name="OuterTemplate.GetSafeStaticUrl">
<xsl:with-param name="UrlColumnName" select="$UrlColumnName"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.GetTitle">
<xsl:param name="Title"/>
<xsl:param name="UrlColumnName"/>
<xsl:param name="UseFileName" select="0"/>
<xsl:choose>
<xsl:when test="string-length($Title) != 0 and $UseFileName = 0">
<xsl:value-of select="$Title" />
</xsl:when>
<xsl:when test="$UseCopyUtil = 'True' and $UseFileName = 0">
<xsl:value-of select="$BlankTitle" />
</xsl:when>
<xsl:otherwise>
<xsl:variable name="FileNameWithExtension">
<xsl:call-template name="OuterTemplate.GetPageNameFromUrl">
<xsl:with-param name="UrlColumnName" select="$UrlColumnName" />
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$UseFileName = 1">
<xsl:call-template name="OuterTemplate.GetFileNameWithoutExtension">
<xsl:with-param name="input" select="$FileNameWithExtension" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$FileNameWithExtension" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="OuterTemplate.FormatColumnIntoUrl">
<xsl:param name="UrlColumnName"/>
<xsl:variable name="Value" select="#*[name()=$UrlColumnName]"/>
<xsl:if test="contains($DataColumnTypes,concat(';',$UrlColumnName,',URL;'))">
<xsl:call-template name="OuterTemplate.FormatValueIntoUrl">
<xsl:with-param name="Value" select="$Value"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not(contains($DataColumnTypes,concat(';',$UrlColumnName,',URL;')))">
<xsl:value-of select="$Value"/>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.FormatValueIntoUrl">
<xsl:param name="Value"/>
<xsl:if test="not(contains($Value,', '))">
<xsl:value-of select="$Value"/>
</xsl:if>
<xsl:if test="contains($Value,', ')">
<xsl:call-template name="OuterTemplate.Replace">
<xsl:with-param name="Value" select="substring-before($Value,', ')"/>
<xsl:with-param name="Search" select="',,'"/>
<xsl:with-param name="Replace" select="','"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.Replace">
<xsl:param name="Value"/>
<xsl:param name="Search"/>
<xsl:param name="Replace"/>
<xsl:if test="contains($Value,$Search)">
<xsl:value-of select="concat(substring-before($Value,$Search),$Replace)"/>
<xsl:call-template name="OuterTemplate.Replace">
<xsl:with-param name="Value" select="substring-after($Value,$Search)"/>
<xsl:with-param name="Search" select="$Search"/>
<xsl:with-param name="Replace" select="$Replace"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="not(contains($Value,$Search))">
<xsl:value-of select="$Value"/>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.GetSafeStaticUrl">
<xsl:param name="UrlColumnName"/>
<xsl:variable name="Url">
<xsl:call-template name="OuterTemplate.FormatColumnIntoUrl">
<xsl:with-param name="UrlColumnName" select="$UrlColumnName"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="cmswrt:EnsureIsAllowedProtocol($Url)"/>
</xsl:template>
<xsl:template name="OuterTemplate.GetColumnDataForUnescapedOutput">
<xsl:param name="Name"/>
<xsl:param name="MustBeOfType"/>
<xsl:if test="contains($DataColumnTypes,concat(';',$Name,',',$MustBeOfType,';'))">
<xsl:value-of select="#*[name()=$Name]"/>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.GetPageNameFromUrl">
<xsl:param name="UrlColumnName"/>
<xsl:variable name="Url">
<xsl:call-template name="OuterTemplate.FormatColumnIntoUrl">
<xsl:with-param name="UrlColumnName" select="$UrlColumnName"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="OuterTemplate.GetPageNameFromUrlRecursive">
<xsl:with-param name="Url" select="$Url"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="OuterTemplate.GetPageNameFromUrlRecursive">
<xsl:param name="Url"/>
<xsl:choose>
<xsl:when test="contains($Url,'/') and substring($Url,string-length($Url)) != '/'">
<xsl:call-template name="OuterTemplate.GetPageNameFromUrlRecursive">
<xsl:with-param name="Url" select="substring-after($Url,'/')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Url"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="OuterTemplate.GetGroupName">
<xsl:param name="GroupName"/>
<xsl:param name="GroupType"/>
<xsl:choose>
<xsl:when test="string-length(normalize-space($GroupName)) = 0">
<xsl:value-of select="$BlankGroup"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$GroupType='URL'">
<xsl:variable name="Url">
<xsl:call-template name="OuterTemplate.FormatValueIntoUrl">
<xsl:with-param name="Value" select="$GroupName"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="OuterTemplate.GetPageNameFromUrlRecursive">
<xsl:with-param name="Url" select="$Url"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="GroupOrder" select="/dsQueryResponse/Rows/Row/#Groupx0020Order" />
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="OuterTemplate.CallPresenceStatusIconTemplate">
<xsl:if test="string-length(#SipAddress) != 0">
<span class="presence-status-icon"><img src="/_layouts/images/imnhdr.gif" onload="IMNRC('{#SipAddress}')" ShowOfflinePawn="1" alt="" id="{concat('MWP_pawn_',$ClientId,'_',#ID,'type=sip')}"/></span>
</xsl:if>
</xsl:template>
<xsl:template name="OuterTemplate.GetFileNameWithoutExtension">
<xsl:param name="input"/>
<xsl:variable name="extension">
<xsl:value-of select="substring-after($input, '.')"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($extension, '.')">
<xsl:variable name="afterextension">
<xsl:call-template name="OuterTemplate.GetFileNameWithoutExtension">
<xsl:with-param name="input" select="$extension"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat(substring-before($input, '.'), $afterextension)"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains($input, '.')">
<xsl:value-of select="substring-before($input, '.')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$input"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
XML Sample
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'>
<s:AttributeType name='ows_Attachments' rs:name='Attachments' rs:number='1'>
<s:datatype dt:type='boolean' dt:maxLength='1' />
</s:AttributeType>
<s:AttributeType name='ows_LinkTitle' rs:name='Title' rs:number='2'>
<s:datatype dt:type='string' dt:maxLength='512' />
</s:AttributeType>
<s:AttributeType name='ows_Creation_x0020_Date_x0020_Overri' rs:name='Creation Date Override' rs:number='3'>
<s:datatype dt:type='datetime' dt:maxLength='8' />
</s:AttributeType>
<s:AttributeType name='ows_News_x0020_Source' rs:name='News Source' rs:number='4'>
<s:datatype dt:type='string' dt:maxLength='512' />
</s:AttributeType>
<s:AttributeType name='ows_Original_x0020_Author' rs:name='Original Author' rs:number='5'>
<s:datatype dt:type='string' dt:maxLength='512' />
</s:AttributeType>
<s:AttributeType name='ows_Original_x0020_Publishing_x0020_' rs:name='Original Publishing Date' rs:number='6'>
<s:datatype dt:type='datetime' dt:maxLength='8' />
</s:AttributeType>
<s:AttributeType name='ows_Month_x0020_ID' rs:name='Month ID' rs:number='7'>
<s:datatype dt:type='variant' dt:lookup='true' dt:maxLength='8009' />
</s:AttributeType>
<s:AttributeType name='ows_ISODate' rs:name='ISODate' rs:number='8'>
<s:datatype dt:type='variant' dt:lookup='true' dt:maxLength='8009' />
</s:AttributeType>
<s:AttributeType name='ows_Category' rs:name='Category' rs:number='9'>
<s:datatype dt:type='string' dt:maxLength='512' />
</s:AttributeType>
<s:AttributeType name='ows_Group_x0020_Order' rs:name='Group Order' rs:number='10'>
<s:datatype dt:type='string' dt:lookup='true' dt:maxLength='512' />
</s:AttributeType>
<s:AttributeType name='ows_Group_x0020_Order_x003a_HomePage' rs:name='Group Order:HomePage Order' rs:number='11'>
<s:datatype dt:type='float' dt:lookup='true' dt:maxLength='8' />
</s:AttributeType>
</s:ElementType>
</s:Schema>
<rs:data>
<z:row ows_Attachments='0' ows_LinkTitle='Math, science basics get a boost with summer camp classes at CSU Stanislaus' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='The Modesto Bee' ows_Original_x0020_Author='NAN AUSTIN' ows_Original_x0020_Publishing_x0020_='2014-06-27 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='Editorials and Commentary' ows_Group_x0020_Order='2;#Editorials and Commentary' ows_Group_x0020_Order_x003a_HomePage='2;#2.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='Fresno State readies for tablet experiment' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='The Fresno Bee' ows_Original_x0020_Author='Hannah Furfao' ows_Original_x0020_Publishing_x0020_='2014-06-27 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='Blogs and Columns' ows_Group_x0020_Order='6;#Blogs and Columns' ows_Group_x0020_Order_x003a_HomePage='6;#6.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='Archived Story' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='Daily Planet' ows_Original_x0020_Author='Clark Kent' ows_Original_x0020_Publishing_x0020_='2014-07-01 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='California News' ows_Group_x0020_Order='4;#California News' ows_Group_x0020_Order_x003a_HomePage='4;#4.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='Test 814' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='Test 814' ows_Original_x0020_Author='Tester' ows_Original_x0020_Publishing_x0020_='2014-08-14 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='CSU Campus News' ows_Group_x0020_Order='1;#CSU Campus News' ows_Group_x0020_Order_x003a_HomePage='1;#1.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='Nat News' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='Internet' ows_Original_x0020_Author='George Castanza' ows_Original_x0020_Publishing_x0020_='2014-06-09 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='National News' ows_Group_x0020_Order='5;#National News' ows_Group_x0020_Order_x003a_HomePage='5;#5.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='Fake News' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='Test' ows_Original_x0020_Author='Testr' ows_Original_x0020_Publishing_x0020_='2014-05-09 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='Editorials and Commentary' ows_Group_x0020_Order='2;#Editorials and Commentary' ows_Group_x0020_Order_x003a_HomePage='2;#2.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='Fake News 2' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='Test 814' ows_Original_x0020_Author='George Castanza' ows_Original_x0020_Publishing_x0020_='2014-01-14 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='Blogs and Columns' ows_Group_x0020_Order='6;#Blogs and Columns' ows_Group_x0020_Order_x003a_HomePage='6;#6.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='December' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='December' ows_Original_x0020_Author='December' ows_Original_x0020_Publishing_x0020_='2014-08-19 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='Editorials and Commentary' ows_Group_x0020_Order='2;#Editorials and Commentary' ows_Group_x0020_Order_x003a_HomePage='2;#2.00000000000000' />
<z:row ows_Attachments='0' ows_LinkTitle='sAS' ows_Creation_x0020_Date_x0020_Overri='2014-08-15 00:00:00' ows_News_x0020_Source='TEST' ows_Original_x0020_Author='TEST' ows_Original_x0020_Publishing_x0020_='2014-08-11 00:00:00' ows_Month_x0020_ID='float;#8.00000000000000' ows_ISODate='string;#201408' ows_Category='National News' ows_Group_x0020_Order='5;#National News' ows_Group_x0020_Order_x003a_HomePage='5;#5.00000000000000' />
</rs:data>
</xml>
Lookup List Columns (List is called Category Order)
Title - Single line of text
HomePage Order - Number
Created By - Person or Group
Modified By - Person or Group
I assumed for GroupType (Using HomePage Order) the GroupType would still be lookup?
Any help is much appreciated.
Thank you for looking.
This a very similar question as XSL: Transforming xml into a sorted multicolumn html table
But (unfortunately) there's an extra requirement: it should be XSLT 1.0 without extension functions, i.e. without using the node-set function.
This is my simplified XML:
<demo>
<config n_columns="3" />
<messages>
<msg date="2011-07-06" title="2nd message" />
<title>message list</title>
<msg date="2011-07-05" title="4th message" />
<msg date="2011-07-06" title="3rd message" />
<msg date="2011-07-07" title="1st message" />
</messages>
</demo>
Using this stylesheet:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<xsl:apply-templates select="demo/messages">
<xsl:with-param name="n_columns" select="number(/demo/config/#n_columns)" />
</xsl:apply-templates>
</xsl:template>
<xsl:template match="messages">
<xsl:param name="n_columns" />
<div>
<xsl:value-of select="concat(./title, ' (', $n_columns, ' columns)')" />
</div>
<table>
<xsl:variable name="cells" select="msg" />
<xsl:apply-templates select="$cells[(position() - 1) mod $n_columns = 0]"
mode="row">
<xsl:with-param name="n_columns" select="$n_columns" />
<xsl:with-param name="cells" select="$cells" />
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="msg" mode="row">
<xsl:param name="n_columns" />
<xsl:param name="cells" />
<xsl:variable name="n_row" select="position()" />
<xsl:variable name="row_cells"
select="$cells[position() > ($n_row - 1) * $n_columns][position() <= $n_columns]" />
<tr>
<xsl:apply-templates select="$row_cells" mode="cell" />
<xsl:call-template name="empty-cells">
<xsl:with-param name="n" select="$n_columns - count($row_cells)" />
</xsl:call-template>
</tr>
</xsl:template>
<xsl:template match="msg" mode="cell">
<td>
<xsl:value-of select="#title" />
</td>
</xsl:template>
<xsl:template name="empty-cells">
<xsl:param name="n" />
<xsl:if test="$n > 0">
<td>
<xsl:attribute name="colspan">
<xsl:value-of select="$n" />
</xsl:attribute>
<xsl:text> </xsl:text>
</td>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Produces this HTML fragment as output:
<div>message list (3 columns)</div>
<table>
<tr>
<td>2nd message</td>
<td>4th message</td>
<td>3rd message</td>
</tr>
<tr>
<td>1st message</td>
<td colspan="2"> </td>
</tr>
</table>
What is obviously missing is the sort part...
Redefining the "cells" variable as follows is actually what I need:
<xsl:variable name="cells">
<xsl:for-each select="msg">
<xsl:sort select="#date" order="descending" />
<xsl:sort select="#title" />
<xsl:copy-of select="." />
</xsl:for-each>
</xsl:variable>
But now I must define another variable to convert the RTF to a nodelist and pass that one to the template I'm applying.
<xsl:variable name="sCells" select="ext:node-set($cells)/*" />
Doing that would produce the following HTML fragment:
<div>message list (3 columns)</div>
<table>
<tr>
<td>1st message</td>
<td>2nd message</td>
<td>3rd message</td>
</tr>
<tr>
<td>4th message</td>
<td colspan="2"> </td>
</tr>
</table>
Unfortunately, my XSLT engine (SAP XML toolkit for java) doesn't support this (or a similar) extension function. Thus I'm looking for another solution that doesn't require the node-set extension function.
I spent quite some time reading all kinds of forums etc., but I really can't figure it out. Perhaps someone has a good idea for an alternative approach? tnx!
This is the follow up based on Dimitre's (slightly extended) solution.
This XML input
<demo>
<config n_columns="3" />
<messages>
<msg date="2011-07-06" title="2nd message" />
<title>message list</title>
<msg date="2011-07-05" title="4th message" />
<msg date="2011-07-06" title="3rd message" />
<msg date="2011-07-07" title="1st message" />
<msg date="2011-07-05" title="5th message" />
<msg date="2011-07-05" title="7th message" />
<msg date="2011-07-05" title="6th message" />
</messages>
</demo>
combined with this XSLT stylesheet
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:variable name="vNumCols" select="/*/config/#n_columns" />
<xsl:variable name="vCells" select="/*/messages/msg" />
<xsl:variable name="vNumCells" select="count($vCells)" />
<xsl:variable name="vNumRows" select="ceiling($vNumCells div $vNumCols)" />
<xsl:variable name="vIndexPatternLength"
select="string-length(concat('', $vNumCells))" />
<xsl:variable name="vIndexPattern">
<xsl:call-template name="padding">
<xsl:with-param name="length" select="$vIndexPatternLength" />
<xsl:with-param name="chars" select="'0'" />
</xsl:call-template>
</xsl:variable>
<xsl:variable name="vSortedIndex">
<xsl:for-each select="$vCells">
<xsl:sort select="#date" order="descending" />
<xsl:sort select="#title" />
<xsl:value-of
select="format-number(count(preceding-sibling::msg) + 1,
$vIndexPattern)" />
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="demo/messages" />
</xsl:template>
<xsl:template match="messages">
<table>
<xsl:for-each select="$vCells[not(position() > $vNumRows)]">
<xsl:variable name="vRow" select="position()" />
<tr>
<xsl:for-each select="$vCells[not(position() > $vNumCols)]">
<xsl:variable name="vCol" select="position()" />
<xsl:variable name="vCell"
select="($vRow - 1) * $vNumCols + $vCol" />
<xsl:variable name="vIndex"
select="substring($vSortedIndex,
($vCell - 1) * $vIndexPatternLength + 1,
$vIndexPatternLength)" />
<xsl:variable name="vMessage"
select="$vCells[position() = $vIndex]" />
<xsl:choose>
<xsl:when test="$vMessage">
<xsl:apply-templates select="$vMessage"
mode="cell" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="empty-cell" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="msg" mode="cell">
<td>
<xsl:apply-templates select="." />
</td>
</xsl:template>
<xsl:template match="msg">
<xsl:value-of select="concat(#date, ' : ', #title)" />
</xsl:template>
<xsl:template name="empty-cell">
<td>
<xsl:text> </xsl:text>
</td>
</xsl:template>
<!-- http://www.exslt.org/str/functions/padding/ -->
<xsl:template name="padding">
<xsl:param name="length" select="0" />
<xsl:param name="chars" select="' '" />
<xsl:choose>
<xsl:when test="not($length) or not($chars)" />
<xsl:otherwise>
<xsl:variable name="string"
select="concat($chars, $chars, $chars, $chars, $chars,
$chars, $chars, $chars, $chars, $chars)" />
<xsl:choose>
<xsl:when test="string-length($string) >= $length">
<xsl:value-of select="substring($string, 1, $length)" />
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="padding">
<xsl:with-param name="length" select="$length" />
<xsl:with-param name="chars" select="$string" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
produces this HTML output
<table>
<tr>
<td>2011-07-07 : 1st message</td>
<td>2011-07-06 : 2nd message</td>
<td>2011-07-06 : 3rd message</td>
</tr>
<tr>
<td>2011-07-05 : 4th message</td>
<td>2011-07-05 : 5th message</td>
<td>2011-07-05 : 6th message</td>
</tr>
<tr>
<td>2011-07-05 : 7th message</td>
<td> </td>
<td> </td>
</tr>
</table>
Thanks Dimitre!
It is difficult, but not impossible to perform the required processing in XSLT 1.0 without using any extension functions:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vNumCols"
select="/*/config/#n_columns"/>
<xsl:variable name="vItems" select="/*/messages/msg"/>
<xsl:variable name="vNumItems" select="count($vItems)"/>
<xsl:variable name="vNumRows" select=
"ceiling($vNumItems div $vNumCols)"/>
<xsl:variable name="vsortedInds">
<xsl:for-each select="$vItems">
<xsl:sort select="#date" order="descending"/>
<xsl:value-of select=
"format-number(count(preceding-sibling::msg)+1,
'0000'
)
"/>
</xsl:for-each>
</xsl:variable>
<xsl:template match="/">
<table>
<xsl:for-each select=
"$vItems[not(position() > $vNumRows)]">
<tr>
<xsl:variable name="vRow" select="position()"/>
<xsl:for-each select="$vItems[not(position() > $vNumCols)]">
<xsl:variable name="vcurIndIndex" select=
"($vRow -1)*$vNumCols + position()"/>
<xsl:variable name="vcurInd" select=
"substring($vsortedInds, 4*($vcurIndIndex -1) +1, 4)"/>
<xsl:variable name="vcurItem" select="$vItems[position()=$vcurInd]"/>
<xsl:if test="$vcurItem">
<td>
<xsl:value-of select="$vcurItem/#title"/>
</td>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the provided XML document:
<demo>
<config n_columns="3" />
<messages>
<msg date="2011-07-06" title="2nd message" />
<title>message list</title>
<msg date="2011-07-05" title="4th message" />
<msg date="2011-07-06" title="3rd message" />
<msg date="2011-07-07" title="1st message" />
</messages>
</demo>
the significant part of the desired output is produced (I am leaving the rest as an exercise to the reader :) ):
<table>
<tr>
<td>1st message</td>
<td>2nd message</td>
<td>3rd message</td>
</tr>
<tr>
<td>4th message</td>
</tr>
</table>
Explanation:
In order to avoid having to convert an RTF to a node-set, we are using a string of the indexes of the sorted elements. Every index occupies four characters (left padded with zeroes when necessary). Then we are using these indexes in populating the rows of the table.
In order to avoid resursion, we are using the Piez method of iteration through N non-node items.
Do note: This solution assumes that the table will not contain more than 9999 cells. If more cells are expected, you can easily change the code, for example:
Replace:
format-number(count(preceding-sibling::msg)+1,
'0000'
)
with:
format-number(count(preceding-sibling::msg)+1,
'00000'
)
And replace:
<xsl:variable name="vcurInd" select=
"substring($vsortedInds, 4*($vcurIndIndex -1) +1, 4)"/>
with
<xsl:variable name="vcurInd" select=
"substring($vsortedInds, 5*($vcurIndIndex -1) +1, 5)"/>
I am using xslt and I want to implement sorting on my href link.
below is the xslt part where I need to implement sorting.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tlink="urn:TridionLinking" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:utils="urn:XSLTExtensions" exclude-result-prefixes="xsl xlink tlink msxsl utils">
<xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="yes" />
<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Title: View All the Destinations XHTML
Description: Render view all the destinations control
Author: Manoj Singh
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
<xsl:include href="dynamic_linking.xslt"/>
<!-- Translations are still loaded here because of XHTML content, research a way around that -->
<xsl:key name="kCityById" match="city" use="#id"/>
<xsl:variable name="vLocations" select="document(concat($publicationPath, /list/resources/#location))/list"/>
<xsl:variable name="destination" select="/list"/>
<xsl:param name="publicationPath"/>
<xsl:param name="pubURL"/>
<xsl:param name="pageURL"/>
<xsl:param name="region"/>
<xsl:param name="country"/>
<!-- offset controls the starting position of the results to show -->
<xsl:param name="offset">0</xsl:param>
<!-- blockSize controls how many results to show on a single page -->
<xsl:param name="blockSize" select="15" />
<!-- Amount of page links to show by default -->
<xsl:param name="pagesShown">20</xsl:param>
<xsl:variable name="totalHits" select="count(/list/destination[contains(concat($pubURL,#url),substring-before($pageURL,'/index.aspx'))])" />
<xsl:template name="calcStart">
<xsl:choose>
<xsl:when test="$offset = 0">1</xsl:when>
<xsl:otherwise>
<xsl:value-of select="($offset * $blockSize) + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="calcEnd">
<xsl:choose>
<xsl:when test="(($offset + 1) * $blockSize) > $totalHits">
<xsl:value-of select="$totalHits"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="($offset + 1) * $blockSize"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="pageNavigation">
<xsl:param name="pageCount"/>
<xsl:param name="currPage"/>
<xsl:param name="showPages">
<xsl:choose>
<xsl:when test="$pagesShown > $pageCount">
<xsl:value-of select="$pageCount"/>
</xsl:when>
<xsl:when test="($pagesShown mod 2) = 0">
<xsl:value-of select="$pagesShown"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pagesShown + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<xsl:param name="currEntry" select="1"/>
<xsl:param name="offset">
<xsl:choose>
<xsl:when test="($currPage < $showPages) or ($pageCount = 1)">0</xsl:when>
<xsl:when test="$currPage > ($pageCount - $showPages + 1)">
<xsl:value-of select="$pageCount - $showPages"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$currPage - ($showPages div 2) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:param>
<!-- Header Processing -->
<xsl:if test="$currEntry = 1">
<xsl:if test="($pageCount > $showPages) and ($currPage >= $showPages)">
<li>... </li>
</xsl:if>
</xsl:if>
<xsl:if test="not ($currEntry > $showPages)">
<li>
<xsl:choose>
<xsl:when test="($currEntry + $offset) = $currPage">
<strong class="thisPage">
<xsl:value-of select="$currEntry + $offset"/>
</strong>
</xsl:when>
<xsl:otherwise>
<a href="{utils:GetHashedUrl(concat($pageURL,'?offset=',$currEntry + $offset - 1,'&blockSize=',$blockSize,'&pagesShown=',$pagesShown))}">
<xsl:value-of select="$currEntry + $offset"/>
</a>
</xsl:otherwise>
</xsl:choose>
</li>
<xsl:if test="not ($currEntry >= $showPages)">
<li class="separatorLine">|</li>
</xsl:if>
<xsl:call-template name="pageNavigation">
<xsl:with-param name="pageCount" select="$pageCount"/>
<xsl:with-param name="currPage" select="$currPage"/>
<xsl:with-param name="showPages" select="$showPages"/>
<xsl:with-param name="currEntry" select="$currEntry + 1"/>
<xsl:with-param name="offset" select="$offset"/>
</xsl:call-template>
</xsl:if>
<!-- Footer Processing -->
<xsl:if test="$currEntry = 1">
<xsl:if test="($pageCount > $showPages) and (($pageCount - $currPage + 1) >= $showPages)">
<li> ...</li>
</xsl:if>
</xsl:if>
</xsl:template>
<xsl:template name="displayPageNavigation">
<div class="continueBar">
<div class="continueBarLeft">
<xsl:variable name="displayStart">
<xsl:call-template name="calcStart"/>
</xsl:variable>
<xsl:variable name="displayEnd">
<xsl:call-template name="calcEnd"/>
</xsl:variable>
<strong>
<xsl:value-of select="utils:TextFormatted('DisplayingDestinations2Arg', concat($displayStart, '-', $displayEnd), $totalHits)"/>
</strong>
</div>
<div class="continueBarRight">
<ul class="paginationLinks">
<!-- Show a back button when available -->
<xsl:choose>
<xsl:when test="$offset > 0">
<li class="noBorder first">
<a class="iconButtonBackBar" href="{$pageURL}?offset={$offset - 1}&blockSize={$blockSize}&pagesShown={$pagesShown}">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</a>
</li>
</xsl:when>
<xsl:otherwise>
<li class="noBorder first">
<span class="iconButtonBackBarOff">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</span>
</li>
</xsl:otherwise>
</xsl:choose>
<!-- Output the page navigation links -->
<xsl:call-template name="pageNavigation">
<xsl:with-param name="pageCount">
<xsl:choose>
<xsl:when test="$blockSize >= $totalHits">1</xsl:when>
<xsl:when test="($totalHits mod $blockSize) != 0">
<xsl:value-of select="ceiling($totalHits div $blockSize)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$totalHits div $blockSize"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="currPage" select="$offset + 1"/>
</xsl:call-template>
<!-- Show a next button when available -->
<xsl:choose>
<xsl:when test="(($offset + 1) * $blockSize) > $totalHits">
<li class="last">
<span class="iconButtonForwardBarOff">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</span>
</li>
</xsl:when>
<xsl:otherwise>
<li class="last">
<a class="iconButtonForwardBar" href="{$pageURL}?offset={$offset + 1}&blockSize={$blockSize}&pagesShown={$pagesShown}">
<xsl:text disable-output-escaping="yes"> </xsl:text>
</a>
</li>
</xsl:otherwise>
</xsl:choose>
</ul>
</div>
<div class="clearBoth">
<xsl:comment/>
</div>
</div>
</xsl:template>
<!-- root match -->
<xsl:template match="/list">
<!--<xsl:value-of select="$publicationPath"/>-->
<div class="brownBarContainer">
<div class="brownBar">
All Destinations
</div>
</div>
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="displayTable">
<tbody>
<tr>
<th scope="col" class="first sortSelected">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconDownSortArrow</xsl:attribute>
</xsl:element>Destination
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Country
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Region
</div>
</th>
</tr>
<xsl:choose>
<xsl:when test="$region='' and $country=''">
<xsl:apply-templates select="destination">
<xsl:sort select="#title" order="ascending" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$country!=''">
<xsl:apply-templates select="destination[city/#id=$vLocations/region/country[#id=$country]/city/#id]">
<xsl:sort select="#title" order="ascending" />
</xsl:apply-templates>
</xsl:when>
<xsl:when test="$region!=''">
<xsl:apply-templates select="destination[city/#id=$vLocations/region[#id=$region]/country/city/#id]">
<xsl:sort select="#title" order="ascending" />
</xsl:apply-templates>
</xsl:when>
</xsl:choose>
</tbody>
</table>
<div class="horRuleWhite">
<hr/>
</div>
<xsl:call-template name="displayPageNavigation" />
</xsl:template>
<xsl:template match="text()"/>
<xsl:template match="destination">
<xsl:variable name="vReverseURL">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="#url"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="vCountryURL">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="substring-after($vReverseURL,'/')"/>
</xsl:call-template>
<xsl:text>/index.aspx</xsl:text>
</xsl:variable>
<xsl:variable name="vRegionURL">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="substring-after(substring-after($vReverseURL,'/'),'/')"/>
</xsl:call-template>
<xsl:text>/index.aspx</xsl:text>
</xsl:variable>
<xsl:variable name="current" select="."/>
<xsl:for-each select="$vLocations">
<tr>
<td class="detail first">
<a class="arrowSmallFront" href="{$current/#url}">
<xsl:value-of select="$current/#title"/>
</a>
</td>
<td class="detail noLeftBorder">
<a class="arrowSmallFront" href="{$vCountryURL}">
<xsl:value-of select="key('kCityById',$current/city/#id)/../#name"/>
</a>
</td>
<td class="detail noLeftBorder">
<a class="arrowSmallFront" href="{$vRegionURL}">
<xsl:value-of select="key('kCityById',$current/city/#id)/../../#name"/>
</a>
</td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template name="reverse">
<xsl:param name="string" select="''"/>
<xsl:if test="$string != ''">
<xsl:call-template name="reverse">
<xsl:with-param name="string" select="substring($string,2)"/>
</xsl:call-template>
<xsl:value-of select="substring($string,1,1)"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Now everything is working fine, however I want to implement sorting on the href link in above xslt.
<tr>
<th scope="col" class="first sortSelected">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconDownSortArrow</xsl:attribute>
</xsl:element>Destination
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Country
</div>
</th>
<th scope="col" class="sortHover">
<div class="thPadding">
<xsl:element name="a">
<xsl:attribute name="href"></xsl:attribute>
<xsl:attribute name="class">iconSortArrowOff</xsl:attribute>
</xsl:element>Region
</div>
</th>
</tr>
1) Destinations.xml
<?xml version="1.0"?>
<list type="Destinations">
<resources location="include/xml/locations.xml">
<publication>481</publication>
</resources>
<destination id="594051" title="Sydney" url="/asiapacific/australia/sydney.aspx" >
<city id="192409" />
</destination>
<destination id="594088" title="Brisbane" url="/asiapacific/australia/brisbane.aspx" >
<city id="192397" />
</destination>
<destination id="594579" title="Dubai" url="/middleeast/uae/dubai.aspx" >
<city id="192855" />
</destination>
<destination id="594580" title="Abu Dhabi" url="/middleeast/uae/abudhabi.aspx" >
<city id="192851" />
</destination>
</list>
2) Locations.xml
<?xml version="1.0"?>
<list type="Locations">
<region id="192393" code="ASIA" name="Asia & the Pacific" shortname="Asia & the Pacific">
<country id="192395" code="AU" name="Australia" shortname="Australia">
<city id="192397" code="BNE" name="Brisbane" shortname="Brisbane">
<airport id="192399" code="BNE" name="Brisbane International Airport" shortname="Brisbane"></airport>
</city>
<city id="192409" code="SYD" name="Sydney" shortname="Sydney">
<airport id="192411" code="SYD" name="Kingsford Smith Airport" shortname="Sydney"></airport>
</city>
</country>
</region>
<region id="192847" code="MEAF" name="The Middle East & Africa" shortname="The Middle East & Africa">
<country id="192849" code="AE" name="United Arab Emirates" shortname="United Arab Emirates">
<city id="192851" code="AUH" name="Abu Dhabi" shortname="Abu Dhabi">
<airport id="192853" code="AUH" name="Abu Dhabi" shortname="Abu Dhabi"></airport>
</city>
<city id="192855" code="DXB" name="Dubai" shortname="Dubai">
<airport id="192857" code="DXB" name="Dubai International Airport" shortname="Dubai"></airport>
</city>
</country>
</region>
</list>
Please suggest!
Thanks.
Before each close tag </xsl:apply-templates> you need to include an <xsl:sort>, e.g.
<xsl:when test="$region='' and $country=''">
<xsl:apply-templates select="destination">
<xsl:sort select="#href" />
</xsl:apply-templates>
</xsl:when>
The above code assumes that #href is an attribute of the destination element, but that's just a guess, since you haven't told us where #href appears in the input. Unless I missed something.
If you need further help please post a sample of your input XML.
On second reading, I wonder if you mean that you want to sort based on which of the three a elements is clicked on? Please clarify, and edit your question to include a sample of your input XML.
OK, based on your comment it's clear that you want to sort based on whichever column the user clicked on last.
To expand on what Alejandro was saying, interactive behavior is outside the scope of XSLT. If you want XSLT to sort based on varying columns, you need to pass that column to the XSLT as an initial parameter. If the XSLT is running on the server, the whole page will reload when you change the sort order of the table. Do you want that?
For instant sorting you could call the XSLT within js on the client, but that's a bit hairy. Usually for interactive sorting, people just sort directly in javascript. Here are some tutorials and implementations:
http://www.javascripttoolbox.com/lib/table/
http://neil.fraser.name/software/tablesort/
http://dynamictable.com/