I have met a problem at my work, I am currently developing on an already built website (that i havn't developed myself), and I'm not really familiar with Umbraco and xslt..
This is the code im working on:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<style>
span.cc { font-size:9px;border:1px solid #000;margin-right:3px; }
</style>
<xsl:variable name="lcletters">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="ucletters">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
<table width="100%">
<xsl:variable name="loc" select="umbraco.library:GetXmlDocument('/media/31087/data.xml', 1)"/>
<xsl:for-each select="$loc/rdsppGenData/generatorData">
<xsl:variable name="tags">
<xsl:if test="(OA23) and (not(OA23 = '-'))">cat_1223 </xsl:if>
<xsl:if test="(OA30) and (not(OA30 = '-'))">cat_1868 </xsl:if>
<xsl:if test="(OA36) and (not(OA36 = '-'))">cat_1227 </xsl:if>
<xsl:if test="(OA60) and (not(OA60 = '-'))">cat_1881 </xsl:if>
<xsl:if test="(F0) and (F0 = 'Z01')">cat_1229 </xsl:if>
<xsl:if test="(F0) and (F0 = 'X01')">cat_1802 </xsl:if>
</xsl:variable>
<xsl:variable name="system">
<xsl:choose>
<xsl:when test="F0">
<xsl:value-of select="F1"/>
</xsl:when>
<xsl:when test="(OA23) or (OA30) or (OA36) or (OA60)">
<xsl:value-of select="system"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="TE">
<xsl:choose>
<xsl:when test="F0">
<xsl:value-of select="F2"/>
</xsl:when>
<xsl:when test="(OA23) or (OA30) or (OA36) or (OA60)">
<xsl:value-of select="TE"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="P1">
<xsl:choose>
<xsl:when test="F0">
<xsl:value-of select="P1s"/>
</xsl:when>
<xsl:when test="(OA23) or (OA30) or (OA36) or (OA60)">
<xsl:value-of select="P1"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="P2">
<xsl:choose>
<xsl:when test="F0">
<xsl:value-of select="P2s"/>
</xsl:when>
<xsl:when test="(OA23) or (OA30) or (OA36) or (OA60)">
<xsl:value-of select="P2"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="description">
<xsl:choose>
<xsl:when test="F0">
<xsl:value-of select="Sdescription"/>
</xsl:when>
<xsl:when test="(OA23) or (OA30) or (OA36) or (OA60)">
<xsl:value-of select="description"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="not(contains($system,'_'))">
<xsl:if test="3 = string-length($system)">
<tr class="sys ovs_{generate-id(msxml:node-set($system))} {$tags}" id="sys_{generate-id(msxml:node-set($system))}" >
<td onclick="sys('{generate-id(msxml:node-set($system))}',1)" class="label">
<xsl:value-of select="$system"/>
</td>
<xsl:variable name="systemname" select="translate($system,$ucletters,$lcletters)" />
<td onclick="sys('{generate-id(msxml:node-set($system))}',1)" class="color">
<xsl:if test="(OA23) and (not(OA23 = '-'))">
<span class="cc" style="width:8px;background-color:#4DAA5B;"> </span>
</xsl:if>
<xsl:if test="(OA30) and (not(OA30 = '-'))">
<span class="cc" style="width:8px;background-color:#EDEA87;"> </span>
</xsl:if>
<xsl:if test="(OA36) and (not(OA36 = '-'))">
<span class="cc" style="width:8px;background-color:#EA6A00;"> </span>
</xsl:if>
<xsl:if test="(OA60) and (not(OA60 = '-'))">
<span class="cc" style="width:8px;background-color:#C897CC;"> </span>
</xsl:if>
<xsl:if test="(F0) and (F0 = 'Z01')">
<span class="cc" style="width:8px;background-color:#829ED8;"> </span>
</xsl:if>
<xsl:if test="(F0) and (F0 = 'X01')">
<span class="cc" style="width:8px;background-color:#9FAD00;"> </span>
</xsl:if>
</td>
<td onclick="sys('{generate-id(msxml:node-set($system))}',1)" class="kw">
<span class="keyword"><xsl:value-of select="$description"/> </span>
</td>
</tr>
</xsl:if>
<xsl:if test="5 = string-length($system)">
<xsl:if test="(3 > string-length($TE)) or (not($TE))">
<xsl:variable name="tags2">
<xsl:if test="(OA23) and (not(OA23 = '-'))">cat_1223 </xsl:if>
<xsl:if test="(OA30) and (not(OA30 = '-'))">cat_1868 </xsl:if>
<xsl:if test="(OA36) and (not(OA36 = '-'))">cat_1227 </xsl:if>
<xsl:if test="(OA60) and (not(OA60 = '-'))">cat_1881 </xsl:if>
<xsl:if test="(F0) and (F0 = 'Z01')">cat_1229 </xsl:if>
<xsl:if test="(F0) and (F0 = 'X01')">cat_1802 </xsl:if>
</xsl:variable>
<xsl:variable name="second_level_id" select="generate-id(msxml:node-set($system))" />
<tr id="sys_{generate-id(msxml:node-set($system))}" style="display:none" class="sys2 {generate-id(msxml:node-set($system))} {$tags2}">
<td style="padding-left:30px; width:190px;" onclick="sys('{generate-id(msxml:node-set($system))}',2)" class="label">
<xsl:value-of select="$system"/>
</td>
<td class="gallery_icon">
</td>
<td onclick="sys('{generate-id(msxml:node-set($system))}',2)"> </td>
<td class="keyword" onclick="sys('{generate-id(msxml:node-set($system))}',2)">
<xsl:value-of select="$description"/>
</td>
</tr>
</xsl:if>
</xsl:if>
<xsl:if test="($TE) and (not($TE = '-')) and (not($TE = ''))">
<xsl:variable name="tags3">
<xsl:if test="(OA23) and (not(OA23 = '-'))">cat_1223 </xsl:if>
<xsl:if test="(OA30) and (not(OA30 = '-'))">cat_1868 </xsl:if>
<xsl:if test="(OA36) and (not(OA36 = '-'))">cat_1227 </xsl:if>
<xsl:if test="(OA60) and (not(OA60 = '-'))">cat_1881 </xsl:if>
<xsl:if test="(F0) and (F0 = 'Z01')">cat_1229 </xsl:if>
<xsl:if test="(F0) and (F0 = 'X01')">cat_1802 </xsl:if>
</xsl:variable>
<xsl:variable name="third_level_id" select="generate-id(msxml:node-set($TE))" />
<tr id="sys_{generate-id(msxml:node-set($TE))}" style="display:none" class="sys3 sub_{second_level_id} {generate-id(msxml:node-set($TE))} {$tags3}">
<td style="padding-left:60px; width:160px;" onclick="sys('{generate-id(msxml:node-set($TE))}',3)" class="label">
<xsl:value-of select="$TE"/>
</td>
<td class="gallery_icon">
</td>
<td onclick="sys('{generate-id(msxml:node-set($TE))}',3)"> </td>
<td class="keyword" onclick="sys('{generate-id(msxml:node-set($TE))}',3)">
<xsl:value-of select="$description"/>
</td>
</tr>
</xsl:if>
<xsl:if test="($P1) and (not($P1 = '-')) and (not($P1 = ''))">
<xsl:variable name="tags4">
<xsl:if test="(OA23) and (not(OA23 = '-'))">cat_1223 </xsl:if>
<xsl:if test="(OA30) and (not(OA30 = '-'))">cat_1868 </xsl:if>
<xsl:if test="(OA36) and (not(OA36 = '-'))">cat_1227 </xsl:if>
<xsl:if test="(OA60) and (not(OA60 = '-'))">cat_1881 </xsl:if>
<xsl:if test="(F0) and (F0 = 'Z01')">cat_1229 </xsl:if>
<xsl:if test="(F0) and (F0 = 'X01')">cat_1802 </xsl:if>
</xsl:variable>
<xsl:variable name="fourth_level_id" select="generate-id(msxml:node-set($P1))" />
<tr id="sys_{generate-id(msxml:node-set($P1))}" style="display:none" class="sys4 sub_{third_level_id} subi_{second_level_id} {generate-id(msxml:node-set($P1))} {$tags4}">
<td style="padding-left:90px; width:130px;" onclick="sys('{generate-id(msxml:node-set($P1))}',4)" class="label">
<xsl:value-of select="$P1"/>
</td>
<td class="gallery_icon">
</td>
<td onclick="sys('{generate-id(msxml:node-set($P1))}',4)"> </td>
<td class="keyword" onclick="sys('{generate-id(msxml:node-set($P1))}',4)">
<xsl:value-of select="$description"/>
</td>
</tr>
</xsl:if>
<xsl:if test="($P2) and (not($P2 = '-')) and (not($P2 = ''))">
<xsl:variable name="tags5">
<xsl:if test="(OA23) and (not(OA23 = '-'))">cat_1223 </xsl:if>
<xsl:if test="(OA30) and (not(OA30 = '-'))">cat_1868 </xsl:if>
<xsl:if test="(OA36) and (not(OA36 = '-'))">cat_1227 </xsl:if>
<xsl:if test="(OA60) and (not(OA60 = '-'))">cat_1881 </xsl:if>
<xsl:if test="(F0) and (F0 = 'Z01')">cat_1229 </xsl:if>
<xsl:if test="(F0) and (F0 = 'X01')">cat_1802 </xsl:if>
</xsl:variable>
<tr id="sys_{generate-id(msxml:node-set($P2))}" style="display:none" class="sys5 subi_{third_level_id} subi_{second_level_id} sub_{fourth_level_id} {generate-id(msxml:node-set($P2))} {$tags5}">
<td style="padding-left:120px; width:100px;" onclick="sys('{generate-id(msxml:node-set($P2))}',5)" class="label">
<xsl:value-of select="$P2"/>
</td>
<td class="gallery_icon">
</td>
<td onclick="sys('{generate-id(msxml:node-set($P2))}',5)"> </td>
<td class="keyword" onclick="sys('{generate-id(msxml:node-set($P2))}',5)">
<xsl:value-of select="$description"/>
</td>
</tr>
</xsl:if>
</xsl:if>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
And i am trying to get the unique ID from the prev. tr and use it in the current row..
I want to use the variable:
<xsl:variable name="second_level_id" select="generate-id(msxml:node-set($system))" />
in this line:
<tr id="sys_{generate-id(msxml:node-set($TE))}" style="display:none" class="sys3 sub_{second_level_id} {generate-id(msxml:node-set($TE))} {$tags3}">
And so on.
If there is ANY better way of doing all of this, where i would get the exact same output, but with the desired variable thingy from above, i would love to hear about it.
Mathias
Here is a way you should be able to accomplish this:
Replace this:
<xsl:for-each select="$loc/rdsppGenData/generatorData">
with:
<xsl:variable name="locItems" select="$loc/rdsppGenData/generatorData" />
<xsl:apply-templates select="$locItems[1]">
<xsl:with-param name="remainder" select="$locItems[position() > 1" />
</xsl:apply-templates>
Add this to your XSLT:
<xsl:template match="generatorData">
<xsl:param name="remainder" />
<xsl:param name="last_second_level_id" />
<xsl:param name="last_third_level_id" />
<!-- Move the contents of the xsl:for-each in here -->
<xsl:apply-templates select="$remainder[1]">
<xsl:with-param name="remainder" select="$remainder[position() > 1]" />
<xsl:with-param name="last_second_level_id" select="$second_level_id" />
<xsl:with-param name="last_thirdlevel_id" select="$second_level_id" />
</xsl:apply-templates>
</xsl:template>
Related
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 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
I am using Apache FOP to convert dynamically generated HTML to PDF. Everything works fine but I am not able to get the table headers repeat when the table is spanned over multiple pages.
Specimen HTML code is :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>AAA</title>
</head>
<body>
<table border="1">
<tr><th>Sample header</th></tr>
<tr>
<td height="500">HELLO - THIS LOOKS GOOD</td>
</tr>
<tr>
<td height="500">HELLO - THIS LOOKS GOOD</td>
</tr>
<tr>
<td height="500">HELLO - THIS LOOKS GOOD</td>
</tr>
<tr>
<td height="500">HELLO - THIS LOOKS GOOD</td>
</tr>
<tr>
<td height="500">HELLO - THIS LOOKS GOOD</td>
</tr>
<tr>
<td height="500">HELLO - THIS LOOKS GOOD</td>
</tr>
</table>
</body>
</html>
XLS:
<xsl:template match="table">
<xsl:apply-templates select="caption"/>
<fo:table table-layout="fixed" width="100%"><xsl:call-template name="common-atts"/>
<xsl:apply-templates select="colgroup|col"/>
<xsl:variable name="tr1" select="(tr|thead/tr|tbody/tr|tfoot/tr)[1]"/>
<xsl:variable name="cols" select="colgroup/col|col"/>
<xsl:call-template name="mock-col">
<xsl:with-param name="cols" select="(count($tr1/*[not(#colspan)])+sum($tr1/*/#colspan))
-(count($cols[not(#colspan)])+sum($cols/#colspan))"/>
</xsl:call-template>
<xsl:apply-templates select="thead|tfoot|tbody"/>
<xsl:if test="tr">
<fo:table-body><xsl:call-template name="common-atts"/>
<xsl:apply-templates select="tr"/>
</fo:table-body>
</xsl:if>
</fo:table>
</xsl:template>
<xsl:template match="xhtml:th|th">
<fo:table-cell font-weight="bold" padding=".1em"><xsl:call-template name="common-atts"/>
<xsl:if test="ancestor::table/#cellpadding = 0">
<xsl:attribute name="padding">0mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#cellpadding = 1">
<xsl:attribute name="padding">0.3mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#cellpadding = 2">
<xsl:attribute name="padding">0.6mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#cellpadding = 3">
<xsl:attribute name="padding">0.9mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#cellpadding = 4">
<xsl:attribute name="padding">1.2mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#cellpadding > 4">
<xsl:attribute name="padding">1.5mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#border = 0">
<xsl:attribute name="border-style">none</xsl:attribute>
<xsl:attribute name="border-width">0.0mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#border = 1">
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-width">0.2mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#border = 2">
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-width">0.3mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#border = 3">
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-width">0.4mm</xsl:attribute>
</xsl:if>
<xsl:if test="ancestor::table/#border > 3">
<xsl:attribute name="border-style">solid</xsl:attribute>
<xsl:attribute name="border-width">0.5mm</xsl:attribute>
</xsl:if>
<xsl:if test="#colspan">
<xsl:attribute name="number-columns-spanned"><xsl:value-of select="#colspan"/></xsl:attribute>
</xsl:if>
<xsl:if test="#rowspan">
<xsl:attribute name="number-rows-spanned"><xsl:value-of select="#rowspan"/></xsl:attribute>
</xsl:if>
<xsl:if test="#bgcolor">
<xsl:attribute name="background-color"><xsl:value-of select="#bgcolor"/></xsl:attribute>
</xsl:if>
<xsl:if test="#color">
<xsl:attribute name="color"><xsl:value-of select="#color"/></xsl:attribute>
</xsl:if>
<fo:block>
<xsl:if test="parent::xhtml:tr/parent::xhtml:thead|parent::tr/parent::thead">
<xsl:attribute name="text-align">center</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</fo:block>
</fo:table-cell>
</xsl:template>
I've the below XML.
<toc-item>
<toc-title>
6A. <content-style font-style="italic">(Repealed 64 of 1989 s.9)
</content-style>
</toc-title>
<toc-pg>U2/6A</toc-pg>
</toc-item>
and i'm running with the below XSLT.
<xsl:template name="toc" match="toc">
<div class="toc">
<div class="toc-part">
<table class="toc-div">
<tbody>
<tr>
<td>
<xsl:for-each select="toc-part/toc-div/toc-item">
<xsl:call-template name="toc-item"/>
</xsl:for-each>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</xsl:template>
<xsl:template name="toc-item" match="toc-item">
<xsl:variable name="tocpg">
<xsl:value-of select="concat('P',normalize-space(current()/toc-pg/text()))"/>
</xsl:variable>
<xsl:variable name="tocpgtag">
<xsl:choose>
<xsl:when test="contains($tocpg,'.')">
<xsl:value-of select="translate($tocpg,'.', '-')"/>
</xsl:when>
<xsl:when test="contains($tocpg,'/')">
<xsl:value-of select="translate($tocpg,'/', '-')"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="chapternumber">
<!-- Get num attribute of parent node -->
<xsl:value-of select="ancestor::chapter[1]/#num"/>
</xsl:variable>
<xsl:variable name="nu">
<xsl:number format="I."/>
</xsl:variable>
<xsl:variable name="Brac">
<xsl:call-template name="get_number_type">
<xsl:with-param name="number_string" select="./#num"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="NewL">
<xsl:value-of select="normalize-space($chapternumber)"/>
</xsl:variable>
<xsl:variable name="size">
<xsl:value-of select="fn:string-length($NewL)"/>
</xsl:variable>
<xsl:variable name="newNum">
<xsl:choose>
<xsl:when test="$size=1">
<xsl:value-of select="concat('0',normalize-space($NewL))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space($NewL)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="d">
<xsl:value-of select="concat('toc-item-',$ThisDocument//ntw:nums[#num=1]/#word,'-level')"/>
</xsl:variable>
<xsl:variable name="new">
<xsl:value-of select="concat('er:#HKWBV1_ORD_',$newNum,'/',$tocpgtag)"/>
</xsl:variable>
<table class="toc-item-first-level">
<tbody>
<tr>
<xsl:choose>
<xsl:when test="./toc-pg">
<xsl:choose>
<xsl:when test="fn:contains(./toc-title,'.')">
<td class="toc-item-num">
<xsl:value-of select="concat(substring-before(./toc-title,'.'),'.')"/>
</td>
</xsl:when>
<xsl:otherwise>
<td colspan="2" align="left" class="padtit">
<xsl:value-of select="./toc-title"/>
</td>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="fn:contains(./toc-title,'.')">
<td class="toc-title">
<xsl:apply-templates select="./toc-title" mode="x"/>
</td>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
<td class="toc-pg">
<xsl:choose>
<xsl:when test="contains(./toc-pg,'.')">
<xsl:value-of select="normalize-space(current()/toc-pg)"/>
</xsl:when>
<xsl:when test="contains(./toc-pg,'/')">
<a href="{$new}">
<xsl:value-of select="normalize-space(current()/toc-pg)"/>
</a>
</xsl:when>
<xsl:otherwise>
<a href="{concat('#pg_',toc-pg)}">
<xsl:value-of select="normalize-space(current()/toc-pg)"/>
</a>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:when>
<xsl:otherwise>
<td align="center" colspan="3">
<span class="font-style-bold">
<xsl:apply-templates select="./toc-title"/>
</span>
</td>
</xsl:otherwise>
</xsl:choose>
</tr>
</tbody>
</table>
<!--</table>-->
</xsl:template>
<xsl:template match="toc-title/text()" mode="x">
<xsl:analyze-string select="substring-after(.,'.')" regex="(\w)">
<xsl:matching-substring>
<xsl:apply-templates select="regex-group(1)"/>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
here what i'm trying to achieve is in my XML in toc-title, there is a number followed by content-style, here my output is having 2 <td>
the number before .
Content after .
if there is no other tag except text after ., i'm able to get the text correctly, and i want to apply-templates for the content after ., please let me know how i can get this done.
here is the demo
Thanks
<article>
<table id="tbl1">
<caption><p>Table 1. Sample Table</p></caption>
<thead>
<tr>
<td colspan="3">I</td>
<td colspan="4">II</td>
</tr>
<tr>
<td>Sl. No.</td>
<td>Name</td>
<td>Place</td>
<td>Subject 1</td>
<td>Subject 2</td>
<td>Subject 3</td>
<td>Grade</td>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="3">1</td>
<td colspan="2">Kishan</td>
<td>95</td>
<td>96</td>
<td rowspan="2">97</td>
<td>A</td>
</tr>
<tr>
<td>Kishan</td>
<td>Bangalore</td>
<td>94</td>
<td>96</td>
<td>A</td>
</tr>
<tr>
<td>Likhith</td>
<td>Bhadravathi</td>
<td>94</td>
<td>94</td>
<td>99</td>
<td>A</td>
</tr>
</tbody>
</table>
</article>
Required OutPut: If colspan is 2 is coded in second cell, then third should not be there, next cell name should be "colname="3" (start Index is 0). Same for rowspan, if present row's first cell having rowspan="3", then next two rows should not have colname="0", those next two rows start cells will have the name="1" (start index is 0, thats why 1 means second cell). Please suggest for the XSLT coding two address both rowspan and colspan present in same table.
<article>
<table id="tbl1">
<caption><p>Table 1. Sample Table</p></caption>
<thead>
<tr>
<td colname="0:0">I</td>
<td colname="0:3">II</td>
</tr>
<tr>
<td colname="1:0">Sl. No.</td>
<td colname="1:1">Name</td>
<td colname="1:2">Place</td>
<td colname="1:3">Subject 1</td>
<td colname="1:4">Subject 2</td>
<td colname="1:5">Subject 3</td>
<td colname="1:6">Grade</td>
</tr>
</thead>
<tbody>
<tr>
<td colname="2:0">1</td>
<td colname="2:1">Kishan</td>
<td colname="2:3">95</td>
<td colname="2:4">96</td>
<td colname="2:5">97</td>
<td colname="2:6">A</td>
</tr>
<tr>
<td colname="3:1">Kishan</td>
<td colname="3:2">Bangalore</td>
<td colname="3:3">94</td>
<td colname="3:4">96</td>
<td colname="3:6">A</td>
</tr>
<tr>
<td colname="4:1">Likhith</td>
<td colname="4:2">Bhadravathi</td>
<td colname="4:3">94</td>
<td colname="4:4">94</td>
<td colname="4:5">99</td>
<td colname="4:6">A</td>
</tr>
</tbody>
</table>
</article>
XSLT code from StackOverFlow site:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--rowspan in table with xslt-->
<xsl:template match="TABLE2">
<tbody>
<xsl:call-template name="processRows">
<xsl:with-param name="rows" select="ROW"/>
</xsl:call-template>
</tbody>
</xsl:template>
<xsl:template name="processRows">
<xsl:param name="rows"/>
<xsl:param name="index" select="1"/>
<!-- Bit vector for the columns -->
<xsl:param name="col1" select="0"/>
<xsl:param name="col2" select="0"/>
<xsl:param name="col3" select="0"/>
<xsl:param name="col4" select="0"/>
<xsl:param name="col5" select="0"/>
<xsl:param name="col6" select="0"/>
<xsl:variable name="cellsBefore2">
<xsl:choose>
<xsl:when test="$col1 > 0">0</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cellsBefore3">
<xsl:choose>
<xsl:when test="$col2 > 0">
<xsl:value-of select="$cellsBefore2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$cellsBefore2 + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cellsBefore4">
<xsl:choose>
<xsl:when test="$col3 > 0">
<xsl:value-of select="$cellsBefore3"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$cellsBefore3 + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cellsBefore5">
<xsl:choose>
<xsl:when test="$col4 > 0">
<xsl:value-of select="$cellsBefore4"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$cellsBefore4 + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="cellsBefore6">
<xsl:choose>
<xsl:when test="$col5 > 0">
<xsl:value-of select="$cellsBefore5"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$cellsBefore5 + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<row>
<xsl:if test="$col1 = 0">
<entry colname="1">
<xsl:value-of select="$rows[$index]/CELL[1]/text()"/>
</entry>
</xsl:if>
<xsl:if test="$col2 = 0">
<entry colname="2">
<xsl:value-of select="$rows[$index]/CELL[$cellsBefore2 + 1]/text()"/>
</entry>
</xsl:if>
<xsl:if test="$col3 = 0">
<entry colname="3">
<xsl:value-of select="$rows[$index]/CELL[$cellsBefore3 + 1]/text()"/>
</entry>
</xsl:if>
<xsl:if test="$col4 = 0">
<entry colname="4">
<xsl:value-of select="$rows[$index]/CELL[$cellsBefore4 + 1]/text()"/>
</entry>
</xsl:if>
<xsl:if test="$col5 = 0">
<entry colname="5">
<xsl:value-of select="$rows[$index]/CELL[$cellsBefore5 + 1]/text()"/>
</entry>
</xsl:if>
<xsl:if test="$col6 = 0">
<entry colname="6">
<xsl:value-of select="$rows[$index]/CELL[$cellsBefore6 + 1]/text()"/>
</entry>
</xsl:if>
</row>
<xsl:if test="$index < count($rows)">
<xsl:call-template name="processRows">
<xsl:with-param name="rows" select="$rows"/>
<xsl:with-param name="index" select="$index + 1"/>
<xsl:with-param name="col1">
<xsl:choose>
<xsl:when test="$col1 > 0">
<xsl:value-of select="$col1 - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($rows[$index]/CELL[1]/#ROWSPAN) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="col2">
<xsl:choose>
<xsl:when test="$col2 > 0">
<xsl:value-of select="$col2 - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($rows[$index]/CELL[$cellsBefore2 + 1]/#ROWSPAN) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="col3">
<xsl:choose>
<xsl:when test="$col3 > 0">
<xsl:value-of select="$col3 - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($rows[$index]/CELL[$cellsBefore3 + 1]/#ROWSPAN) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="col4">
<xsl:choose>
<xsl:when test="$col4 > 0">
<xsl:value-of select="$col4 - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($rows[$index]/CELL[$cellsBefore4 + 1]/#ROWSPAN) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="col5">
<xsl:choose>
<xsl:when test="$col5 > 0">
<xsl:value-of select="$col5 - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($rows[$index]/CELL[$cellsBefore5 + 1]/#ROWSPAN) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="col6">
<xsl:choose>
<xsl:when test="$col6 > 0">
<xsl:value-of select="$col6 - 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="number($rows[$index]/CELL[$cellsBefore6 + 1]/#ROWSPAN) - 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
This is not at all simple. Basically, you are asking how to render an HTML table visually, by positioning each cell on a (equi-spaced) x-y grid of rows and columns.
This is complex, because the position of each cell depends not only on the width (colspan) of the preceding cells in the same row, but also on the position of cells in preceding rows that span more than one row. This position is not known before the preceding cells themselves have been processed - so this is a giant render-as-you-go cascading operation.
Due to this complexity, I suggest solving the basic problem in isolation first, before introducing additional constraints (e.g. separate header rows or numbers starting from 0).
For testing, I have used the following table1 as the input:
<table border="1">
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
</tr>
<tr>
<td rowspan="2">A</td>
<td colspan="2">B</td>
</tr>
<tr>
<td>C</td>
<td>D</td>
</tr>
<tr>
<td>E</td>
<td rowspan="2" colspan="2">F</td>
</tr>
<tr>
<td>G</td>
</tr>
<tr>
<td colspan="3">H</td>
</tr>
</table>
Applying the folowing stylesheet:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/table">
<table>
<xsl:text>
</xsl:text>
<xsl:call-template name="generate-rows">
<xsl:with-param name="current-row" select="1"/>
<xsl:with-param name="last-row" select="count(tr)"/>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name="generate-rows">
<xsl:param name="current-row"/>
<xsl:param name="last-row"/>
<xsl:param name="result" select="some-dummy-node-to-make-this-a-node"/>
<!-- append current-row to previous result -->
<xsl:variable name="new-result">
<xsl:copy-of select="$result"/>
<row num="{$current-row}">
<xsl:text>
</xsl:text>
<!-- generate cells for current-row -->
<xsl:call-template name="generate-cells">
<xsl:with-param name="current-row" select="$current-row"/>
<xsl:with-param name="current-cell" select="1"/>
<xsl:with-param name="x" select="1"/>
<xsl:with-param name="last-cell" select="count(tr[$current-row]/td)"/>
<xsl:with-param name="previous-rows" select="$result"/>
</xsl:call-template>
</row>
<xsl:text>
</xsl:text>
</xsl:variable>
<xsl:choose>
<xsl:when test="$current-row < $last-row">
<!-- recursive call -->
<xsl:call-template name="generate-rows">
<xsl:with-param name="current-row" select="$current-row + 1"/>
<xsl:with-param name="last-row" select="$last-row"/>
<xsl:with-param name="result" select="$new-result"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- return result -->
<xsl:copy-of select="$new-result"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="generate-cells">
<xsl:param name="current-row"/>
<xsl:param name="current-cell"/>
<xsl:param name="x"/>
<xsl:param name="last-cell"/>
<xsl:param name="previous-rows"/>
<xsl:variable name="my-cell" select="tr[$current-row]/td[$current-cell]" />
<xsl:choose>
<!-- if there's a collision, move one place to the right -->
<xsl:when test="exsl:node-set($previous-rows)/row/cell[#x <= $x and #x + #width > $x and #y + #height > $current-row]">
<xsl:call-template name="generate-cells">
<xsl:with-param name="current-row" select="$current-row"/>
<xsl:with-param name="current-cell" select="$current-cell"/>
<xsl:with-param name="x" select="$x + 1"/>
<xsl:with-param name="last-cell" select="$last-cell"/>
<xsl:with-param name="previous-rows" select="$previous-rows"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="width">
<xsl:choose>
<xsl:when test="$my-cell/#colspan">
<xsl:value-of select="$my-cell/#colspan"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="height">
<xsl:choose>
<xsl:when test="$my-cell/#rowspan">
<xsl:value-of select="$my-cell/#rowspan"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:text> </xsl:text>
<cell num="{$current-cell}" y="{$current-row}" x="{$x}" width="{$width}" height="{$height}">
<xsl:value-of select="$my-cell"/>
</cell>
<xsl:text>
</xsl:text>
<xsl:if test="$current-cell < $last-cell">
<xsl:call-template name="generate-cells">
<xsl:with-param name="current-row" select="$current-row"/>
<xsl:with-param name="current-cell" select="$current-cell + 1"/>
<xsl:with-param name="x" select="$x + $width"/>
<xsl:with-param name="last-cell" select="count(tr[$current-row]/td)"/>
<xsl:with-param name="previous-rows" select="$previous-rows"/>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
produces the following result:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<row num="1">
<cell num="1" y="1" x="1" width="1" height="1">Column 1</cell>
<cell num="2" y="1" x="2" width="1" height="1">Column 2</cell>
<cell num="3" y="1" x="3" width="1" height="1">Column 3</cell>
</row>
<row num="2">
<cell num="1" y="2" x="1" width="1" height="2">A</cell>
<cell num="2" y="2" x="2" width="2" height="1">B</cell>
</row>
<row num="3">
<cell num="1" y="3" x="2" width="1" height="1">C</cell>
<cell num="2" y="3" x="3" width="1" height="1">D</cell>
</row>
<row num="4">
<cell num="1" y="4" x="1" width="1" height="1">E</cell>
<cell num="2" y="4" x="2" width="2" height="2">F</cell>
</row>
<row num="5">
<cell num="1" y="5" x="1" width="1" height="1">G</cell>
</row>
<row num="6">
<cell num="1" y="6" x="1" width="3" height="1">H</cell>
</row>
</table>
As you can see, the x-y positioning of each cell corresponds to the visual rendering of the original table in a browser:
--
1. From http://en.wikipedia.org/wiki/Help:Table
For XSLT 2.0:
Change the stylesheet declaration to:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Change line #66 to:
<xsl:when test="$previous-rows/row/cell[#x <= $x and #x + #width > $x and #y + #height > $current-row]">