Switching Math to %Reported from just a count of Present - xslt

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">&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">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="$groupid='2'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="$groupid='3'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="$groupid='4'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="$groupid='5'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="$groupid='6'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</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">&nbsp;</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">&nbsp;</xsl:text>
</xsl:when>
<xsl:when test="$groupid='2'">
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</xsl:text>
<xsl:text disable-output-escaping="yes" ddwrt:nbsp-preserve="yes">&nbsp;</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">&nbsp;</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">

Related

Recursive Template Generating Extra Stuff

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>

xsl for table view in sharepoint

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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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">&nbsp;</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

Display alternate style class in XSLT

I want to display alternate style class in XSLT.
Here is my code:
<xsl:variable name="oddEven" select="1" />
<xsl:for-each select="//ProfileBR">
<xsl:variable name="i" select="((position() - 1) * 2) + 1" />
<xsl:variable name="iBR" select="substring(//BRValue,$i,1)" />
<xsl:variable name="jBR" select="substring(//BRValue,$i+1,1)" />
<xsl:if test="$iBR='1' or $jBR='1'">
<xsl:choose>
<xsl:when test="$oddEven='1'">
<tr class="sbListOddCell">
<xsl:if test="$iBR=0">
<td></td>
</xsl:if>
<xsl:call-template name="JobInfoSection">
<xsl:with-param name="ii" select="$i"/>
<xsl:with-param name="jj" select="$i+1"/>
<xsl:with-param name="iiBR" select="$iBR"/>
<xsl:with-param name="jjBR" select="$jBR"/>
</xsl:call-template>
<xsl:if test="$jBR=0">
<td></td>
</xsl:if>
</tr>
<xsl:variable name="oddEven" select="0" />
</xsl:when>
<xsl:otherwise>
<tr class="sbListEvenCell">
<xsl:if test="$iBR=0">
<td></td>
</xsl:if>
<xsl:call-template name="JobInfoSection">
<xsl:with-param name="ii" select="$i"/>
<xsl:with-param name="jj" select="$i+1"/>
<xsl:with-param name="iiBR" select="$iBR"/>
<xsl:with-param name="jjBR" select="$jBR"/>
</xsl:call-template>
<xsl:if test="$jBR=0">
<td></td>
</xsl:if>
</tr>
<xsl:variable name="oddEven" select="1" />
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
Currently the oddEven logic is not working as the value does not persist.
Note: The position is not at all related with the display. If the condition satisfy than only display the <tr> else not.
I think using the CSS will be better for this case or may be Javascript ..
table tr:nth-child(odd) td{
}
table tr:nth-child(even) td{
}
I think you can also use a counter if you have changed the loop style to be a recursive like this
<xsl:template name="loop">
<xsl:param name="other param"/>
<xsl:param name="count"/>
<!-- logic then recurse and pass the counter with $counter + 1-->
</xsl:template>
As you can each time path the param with a new value.
I hope this could help!

How do I Replace the Name of A Group on A SharePoint 2010 Content Query Webpart

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.

Converting simple markdown(string) to html with xslt

I'm transforming my XSLT-stylesheets into documentation, and I want a rich experience within the comment nodes for each code-chunk, therefore I want to convert the following comment and output as xhtml:
String:
# This is a title with __bold__ text and *italic* #
This is just a normal line
- list point with some __bold__
- list point with a "link"[http://www.stackoverflow.com]
Wanted output:
<h1> This is a title with <strong>bold</strong> and <span>italic</span> </h1>
<p>This is a normal line</p>
<ul>
<li>list point with some <strong>bold</strong></li>
<li>list point with a link</li>
</ul>
I tried with a recursive function that uses xsl:analyze-string recursively from a ruleset, but can't find a solution that works really well.
Anyone have done this lately, or is there some frameworks out there that has functions to do this ?
thanx in advance! :)
Edit: Added one dirty example:
<!-- Output comments -->
<xsl:template match="comment()" mode="COMMENT">
<xsl:copy-of select="ips:groupReplace(normalize-space(.),
'
(.*)(\n|\r)(.*),
(.*)\*(.*)\*(.*),
(.*)\*\*(.*)\*\*(.*),
(.*)__(.*)__(.*),
(.*)#(.*)#(.*),
(.*)-(.*)
',
'
br,
span.italic,
span.bold,
strong,
h1,
li
')" />
</xsl:template>
<!-- Initializing the iterateRegex function -->
<xsl:function name="ips:groupReplace">
<xsl:param name="string" as="xs:string" />
<xsl:param name="search" />
<xsl:param name="replace" />
<xsl:variable name="regex" select="tokenize($search, ',')" />
<xsl:variable name="replacements" select="tokenize($replace, ',')" />
<xsl:copy-of select="ips:iterateRegex(count($replacements), $string, $regex, $replacements)" />
</xsl:function>
<!-- Iterate each regex -->
<xsl:function name="ips:iterateRegex">
<xsl:param name="counter" />
<xsl:param name="string" />
<xsl:param name="list_regex" />
<xsl:param name="list_replace" />
<xsl:variable name="newStr">
<xsl:analyze-string select="$string" regex="{normalize-space($list_regex[$counter])}" flags="xm">
<xsl:matching-substring>
<xsl:variable name="cc" select="contains($list_replace[$counter], '.')" />
<xsl:variable name="tag" select="normalize-space(if ($cc) then (substring-before($list_replace[$counter], '.')) else ($list_replace[$counter]))" />
<xsl:copy-of select="regex-group(1)" />
<xsl:choose>
<xsl:when test="normalize-space(regex-group(2)) = ''">
<xsl:element name="{$tag}" />
</xsl:when>
<xsl:otherwise>
<xsl:element name="{$tag}" >
<xsl:if test="$cc">
<xsl:attribute name="class" select="substring-after($list_replace[$counter],'.')" />
</xsl:if>
<xsl:copy-of select="regex-group(2)" />
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="regex-group(3)" />
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:copy-of select="." />
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:variable>
<xsl:variable name="count" select="number($counter) - 1" />
<xsl:choose>
<xsl:when test="$count > 0">
<xsl:copy-of select="ips:iterateRegex($count, $newStr, $list_regex, $list_replace)" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$newStr" />
</xsl:otherwise>
</xsl:choose>
</xsl:function>
I think you would need a parser. So this stylesheet implements a verbose one:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="text" name="block">
<xsl:param name="pString" select="."/>
<xsl:if test="$pString != ''">
<xsl:choose>
<xsl:when test="starts-with($pString,'#')">
<xsl:call-template name="header">
<xsl:with-param name="pString"
select="substring($pString,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with($pString,'
')">
<xsl:call-template name="list">
<xsl:with-param name="pString"
select="substring($pString,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="paragraph">
<xsl:with-param name="pString"
select="$pString"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template name="header">
<xsl:param name="pString"/>
<xsl:variable name="vInside"
select="substring-before($pString,'#
')"/>
<xsl:choose>
<xsl:when test="$vInside != ''">
<h1>
<xsl:call-template name="inline">
<xsl:with-param name="pString" select="$vInside"/>
</xsl:call-template>
</h1>
<xsl:call-template name="block">
<xsl:with-param name="pString"
select="substring-after($pString,'#
')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="paragraph">
<xsl:with-param name="pString"
select="concat('#',$pString)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="list">
<xsl:param name="pString"/>
<xsl:variable name="vCheckList" select="starts-with($pString,'- ')"/>
<xsl:choose>
<xsl:when test="$vCheckList">
<ul>
<xsl:call-template name="listItem">
<xsl:with-param name="pString" select="$pString"/>
</xsl:call-template>
</ul>
<xsl:call-template name="block">
<xsl:with-param name="pString">
<xsl:call-template name="afterlist">
<xsl:with-param name="pString" select="$pString"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="block">
<xsl:with-param name="pString" select="$pString"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="paragraph">
<xsl:param name="pString"/>
<xsl:choose>
<xsl:when test="contains($pString,'
')">
<p>
<xsl:value-of select="substring-before($pString,'
')"/>
</p>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:value-of select="$pString"/>
</p>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="block">
<xsl:with-param name="pString"
select="substring-after($pString,'
')"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="afterlist">
<xsl:param name="pString"/>
<xsl:choose>
<xsl:when test="starts-with($pString,'- ')">
<xsl:call-template name="afterlist">
<xsl:with-param name="pString"
select="substring-after($pString,'
')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pString"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="listItem">
<xsl:param name="pString"/>
<xsl:if test="starts-with($pString,'- ')">
<li>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="substring-before(substring($pString,3),'
')"/>
</xsl:call-template>
</li>
<xsl:call-template name="listItem">
<xsl:with-param name="pString"
select="substring-after($pString,'
')"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="inline">
<xsl:param name="pString" select="."/>
<xsl:if test="$pString != ''">
<xsl:choose>
<xsl:when test="starts-with($pString,'__')">
<xsl:call-template name="strong">
<xsl:with-param name="pString"
select="substring($pString,3)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with($pString,'*')">
<xsl:call-template name="span">
<xsl:with-param name="pString"
select="substring($pString,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with($pString,'"')">
<xsl:call-template name="link">
<xsl:with-param name="pString"
select="substring($pString,2)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring($pString,1,1)"/>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="substring($pString,2)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template name="strong">
<xsl:param name="pString"/>
<xsl:variable name="vInside" select="substring-before($pString,'__')"/>
<xsl:choose>
<xsl:when test="$vInside != ''">
<strong>
<xsl:value-of select="$vInside"/>
</strong>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="substring-after($pString,'__')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'__'"/>
<xsl:call-template name="inline">
<xsl:with-param name="pString" select="$pString"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="span">
<xsl:param name="pString"/>
<xsl:variable name="vInside" select="substring-before($pString,'*')"/>
<xsl:choose>
<xsl:when test="$vInside != ''">
<span>
<xsl:value-of select="$vInside"/>
</span>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="substring-after($pString,'*')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'*'"/>
<xsl:call-template name="inline">
<xsl:with-param name="pString" select="$pString"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="link">
<xsl:param name="pString"/>
<xsl:variable name="vInside"
select="substring-before($pString,'"')"/>
<xsl:choose>
<xsl:when test="$vInside != ''">
<xsl:call-template name="href">
<xsl:with-param name="pString"
select="substring-after($pString,'"')"/>
<xsl:with-param name="pInside" select="$vInside"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'"'"/>
<xsl:call-template name="inline">
<xsl:with-param name="pString" select="$pString"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="href">
<xsl:param name="pString"/>
<xsl:param name="pInside"/>
<xsl:variable name="vHref"
select="substring-before(substring($pString,2),']')"/>
<xsl:choose>
<xsl:when test="starts-with($pString,'[') and $vHref != ''">
<a href="{$vHref}">
<xsl:value-of select="$pInside"/>
</a>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="substring-after($pString,']')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('"',$pInside,'"')"/>
<xsl:call-template name="inline">
<xsl:with-param name="pString" select="$pString"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
With this input:
<text>
# This is a title with __bold__ text and *italic* #
This is just a normal line
- list point with some __bold__
- list point with a "link"[http://www.stackoverflow.com]
</text>
Output:
<h1> This is a title with
<strong>bold</strong> text and
<span>italic</span>
</h1>
<p>This is just a normal line</p>
<ul>
<li>list point with some
<strong>bold</strong>
</li>
<li>list point with a
link
</li>
</ul>
Note: Look how many templates are similar (they follow a pattern), so these could be parametrized. I didn't do that in this case because there seems to be more questions which need some sort of parser, so by the end of the week I will repost an answer implementing functional parser and parser combinators pattern that make very easy to write parsers (just writing its grammar rules).
Edit: XSLT 2.0 solution. This stylesheet:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="text">
<xsl:param name="pString" select="."/>
<xsl:analyze-string select="$pString"
regex="(#(.*)#
)|((- (.*)
)+)">
<xsl:matching-substring>
<xsl:choose>
<xsl:when test="regex-group(1)">
<h1>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="regex-group(2)"/>
</xsl:call-template>
</h1>
</xsl:when>
<xsl:when test="regex-group(3)">
<ul>
<xsl:call-template name="list">
<xsl:with-param name="pString"
select="regex-group(3)"/>
</xsl:call-template>
</ul>
</xsl:when>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:if test=".!='
'">
<p>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="normalize-space(.)"/>
</xsl:call-template>
</p>
</xsl:if>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template name="list">
<xsl:param name="pString"/>
<xsl:analyze-string select="$pString" regex="- (.*)
">
<xsl:matching-substring>
<li>
<xsl:call-template name="inline">
<xsl:with-param name="pString"
select="regex-group(1)"/>
</xsl:call-template>
</li>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>
<xsl:template name="inline">
<xsl:param name="pString" select="."/>
<xsl:analyze-string select="$pString"
regex="(__(.*)__)|(\*(.*)\*)|("(.*)"\[(.*)\])">
<xsl:matching-substring>
<xsl:choose>
<xsl:when test="regex-group(1)">
<strong>
<xsl:value-of select="regex-group(2)"/>
</strong>
</xsl:when>
<xsl:when test="regex-group(3)">
<span>
<xsl:value-of select="regex-group(4)"/>
</span>
</xsl:when>
<xsl:when test="regex-group(5)">
<a href="{regex-group(7)}">
<xsl:value-of select="regex-group(6)"/>
</a>
</xsl:when>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
</xsl:stylesheet>
Output:
<h1> This is a title with
<strong>bold</strong> text and
<span>italic</span>
</h1>
<p>This is just a normal line</p>
<ul>
<li>list point with some
<strong>bold</strong>
</li>
<li>list point with a
link
</li>
</ul>
This transformation (111 lines):
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:my="my:my"
exclude-result-prefixes="xml xsl xs my">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="vLines" select="tokenize(., '\n')"/>
<xsl:sequence select="my:parse-lines($vLines)"/>
</xsl:template>
<xsl:function name="my:parse-lines" as="element()*">
<xsl:param name="pLines" as="xs:string*"/>
<xsl:sequence select=
"my:parse-line($pLines, 1, count($pLines))"/>
</xsl:function>
<xsl:function name="my:parse-line" as="element()*">
<xsl:param name="pLines" as="xs:string*"/>
<xsl:param name="pLineNum" as="xs:integer"/>
<xsl:param name="pTotalLines" as="xs:integer"/>
<xsl:if test="not($pLineNum gt $pTotalLines)">
<xsl:variable name="vLine" select="$pLines[$pLineNum]"/>
<xsl:variable name="vLineLength"
select="string-length($vLine)"/>
<xsl:choose>
<xsl:when test=
"starts-with($vLine, '#')
and
ends-with($vLine, '#')
">
<xsl:variable name="vInnerString"
select="substring($vLine, 2, $vLineLength -2)"/>
<h1>
<xsl:sequence select="my:parse-string($vInnerString)"/>
</h1>
<xsl:sequence select=
"my:parse-line($pLines, $pLineNum+1, $pTotalLines)"/>
</xsl:when>
<xsl:when test=
"starts-with($vLine, '- ')
and
not(starts-with($pLines[$pLineNum -1], '- '))
">
<ul>
<li>
<xsl:sequence select="my:parse-string(substring($vLine, 2))"/>
</li>
<xsl:sequence select=
"my:parse-line($pLines, $pLineNum+1, $pTotalLines)"/>
</ul>
</xsl:when>
<xsl:when test="starts-with($vLine, '- ')">
<li>
<xsl:sequence select="my:parse-string(substring($vLine, 2))"/>
</li>
<xsl:sequence select=
"my:parse-line($pLines, $pLineNum+1, $pTotalLines)"/>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:sequence select="my:parse-string($vLine)"/>
</p>
<xsl:sequence select=
"my:parse-line($pLines, $pLineNum+1, $pTotalLines)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:function>
<xsl:function name="my:parse-string" as="node()*">
<xsl:param name="pS" as="xs:string"/>
<xsl:analyze-string select="$pS" flags="x" regex=
'(__(.*?)__)
|
(\*(.*?)\*)
|
("(.*?)"\[(.*?)\])
'>
<xsl:matching-substring>
<xsl:choose>
<xsl:when test="regex-group(1)">
<strong>
<xsl:sequence select="my:parse-string(regex-group(2))"/>
</strong>
</xsl:when>
<xsl:when test="regex-group(3)">
<span>
<xsl:sequence select="my:parse-string(regex-group(4))"/>
</span>
</xsl:when>
<xsl:when test="regex-group(5)">
<a href="{regex-group(7)}">
<xsl:sequence select="regex-group(6)"/>
</a>
</xsl:when>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:function>
</xsl:stylesheet>
when applied on this XML document (the provided text complicated with nested constructs and wrapped in an element):
<t># This is a title with __bold__ text and *italic* #
This is just a normal line
- list point with some __bold__
- list point with a __*"link"[http://www.stackoverflow.com]*__</t>
produces the wanted, correct output:
<h1> This is a title with <strong>bold</strong> text and <span>italic</span>
</h1>
<p>This is just a normal line</p>
<p/>
<ul>
<li> list point with some <strong>bold</strong>
</li>
<li> list point with a <strong>
<span>
link
</span>
</strong>
</li>
</ul>
Do note: The RegEx mechanism of XPath 2.0 and XSLT 2.0 is adequate for solving this problem.