Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Pivot Reports

From: "D O" <djo267@----------->
To:
Date: 1/5/2007 3:15:00 PM
Do you have a sample html of the output you want, given the test data?
This way we can see what exactly you are trying to do...

thanks, dan




Dan Ochs, Principal Consultant
Wrycan, Inc
http://www.wrycan.com
dan(dot)ochs(at)wrycan(dot)com

On 1/5/07, Vitaliy Paykov <vpay@xxxxxxxxx> wrote:
This is my XSL template:



<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="b" match="pivotrow" use="."/>
<xsl:key name="c" match="pivotcol" use="."/>
<xsl:template match="/">
<xsl:for-each select="/notice/records/record/row">
  <br/>
<xsl:for-each select="pivot1">
      <table border="1" cellspacing="0" class="stn">
          <tr>
            <th>*</th>
            <xsl:for-each select="item/pivotrow">
              <xsl:sort select="."/>
              <xsl:variable name="vpivotrow" select="."/>
              <th>
                <xsl:value-of select="."/>
              </th>
            </xsl:for-each>
            <th>total</th>
          </tr>
        <xsl:for-each
select="item/pivotcol[generate-id(.)=generate-id(key('c',.)[1])]">
          <xsl:sort select="."/>
          <xsl:variable name="vpivotcol" select="."/>
          <tr>
            <th><xsl:value-of select="."/></th>
            <xsl:for-each
select="../../item/pivotrow[generate-id(.)=generate-id(key('b',.)[1])]">
              <xsl:variable name="vpivotrow" select="."/>
              <td>
                <xsl:if test="not(../../item[pivotcol=$vpivotcol and
pivotrow=$vpivotrow])">-</xsl:if>
                <xsl:if test="../../item[pivotcol=$vpivotcol and
pivotrow=$vpivotrow]"><xsl:value-of
select="../../item[pivotcol=$vpivotcol and
pivotrow=$vpivotrow]/TOTALS"/></xsl:if>
              </td>
            </xsl:for-each>
            <td><xsl:value-of
select="sum(../../item[pivotcol=$vpivotcol]/TOTALS)"/></td>
          </tr>
        </xsl:for-each>
          <tr>
            <th>total</th>
            <xsl:for-each
select="item/pivotrow[generate-id(.)=generate-id(key('b',.)[1])]">
              <xsl:sort select="."/>
              <xsl:variable name="vpivotrow" select="."/>
              <td>
                <xsl:value-of
select="sum(../../item[pivotrow=$vpivotrow]/TOTALS)"/>
              </td>
            </xsl:for-each>
            <td><xsl:value-of select="sum(item/TOTALS)"/></td>
          </tr>
      </table>
</xsl:for-each>

<xsl:for-each select="pivot2">
      <table border="1" cellspacing="0" class="stn">
          <tr>
            <th>*</th>
            <xsl:for-each select="item/pivotrow">
              <xsl:sort select="."/>
              <xsl:variable name="vpivotrow" select="."/>
              <th>
                <xsl:value-of select="."/>
              </th>
            </xsl:for-each>
            <th>total</th>
          </tr>
        <xsl:for-each
select="item/pivotcol[generate-id(.)=generate-id(key('c',.)[1])]">
          <xsl:sort select="."/>
          <xsl:variable name="vpivotcol" select="."/>
          <tr>
            <th><xsl:value-of select="."/></th>
            <xsl:for-each
select="../../item/pivotrow[generate-id(.)=generate-id(key('b',.)[1])]">
              <xsl:variable name="vpivotrow" select="."/>
              <td>
                <xsl:if test="not(../../item[pivotcol=$vpivotcol and
pivotrow=$vpivotrow])">-</xsl:if>
                <xsl:if test="../../item[pivotcol=$vpivotcol and
pivotrow=$vpivotrow]"><xsl:value-of
select="../../item[pivotcol=$vpivotcol and
pivotrow=$vpivotrow]/TOTALS"/></xsl:if>
              </td>
            </xsl:for-each>
            <td><xsl:value-of
select="sum(../../item[pivotcol=$vpivotcol]/TOTALS)"/></td>
          </tr>
        </xsl:for-each>
          <tr>
            <th>total</th>
            <xsl:for-each
select="item/pivotrow[generate-id(.)=generate-id(key('b',.)[1])]">
              <xsl:sort select="."/>
              <xsl:variable name="vpivotrow" select="."/>
              <td>
                <xsl:value-of
select="sum(../../item[pivotrow=$vpivotrow]/TOTALS)"/>
              </td>
            </xsl:for-each>
            <td><xsl:value-of select="sum(item/TOTALS)"/></td>
          </tr>
      </table>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

In result i have right view of first table, in second table i have only
columns and rows which not exists in first table etc.

Seems I have version 1.0



Abel Braaksma wrote:
> Vitaliy Paykov wrote:
>> I need xsl template for crosstab building.
>>
>> But not for one table, i need several crosstabs in one xsl template.
>>
>> My XML:
>
> Where is your XSLT that you've got so far and where did you get stuck?
> What is the XSLT version you use?
>
> -- Abel
>
>


--
*/Best regards,
Vitaliy Paykov/*
e-mail: vpay@xxxxxxxxx
ext: 1120
ICQ: 220022522
*/ISD QA/*


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent