[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Conditionally create an html table based upon exi

Subject: RE: Conditionally create an html table based upon existance of one or two node sets
From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx>
Date: Tue, 30 Mar 2010 20:11:52 +0200
RE:  Conditionally create an html table based upon  exi
This template is wrong.  you should remove the <xsl:for-each> around the <TR>
since it already get's called for every BoxDimension it matches,


<xsl:template match="Dimension">
  <xsl:for-each select=".">
    <TR   BGCOLOR="D3D3D3" >
      <TD width="65%">     <xsl:value-of select="./@Name" />        </TD>
      <TD>                 <xsl:value-of select="../../@Name" />    </TD>
    </TR>
  </xsl:for-each>
</xsl:template>


Cheers,
Robby
-----Original Message-----
From: Rod Kane [mailto:rkane@xxxxxxxxxxxxxxxxxx]
Sent: Tuesday, March 30, 2010 8:02 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Conditionally create an html table based upon existance of one
or two node sets




Hello,

I need to create a table if either the second and third "apply-template"
 directives return nodes, and otherwise create nothing .

 "Fiscal Year" is the Dimension name and C02 and C09 are the "Column Group
Name"s, but the table creation is not quite correct as the rows are not
displayed correctly.

Thank you in advance.

Rod



<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:template match="/">
<HTML>
<BODY>
       <xsl:apply-templates select="Template"/>
       <xsl:apply-templates
select="Template/Queries/DataQuery/Abstract/Columns/Groups/Group/Dimensions/D
imension[count(*) = 0]"/>
       <xsl:apply-templates
select="Template/Queries/DataQuery/Abstract/Rows/Groups/Group/Dimensions/Dime
nsion[count(*) = 0]"/>
</BODY>
</HTML>
</xsl:template>


<xsl:template match="Template">
       <B>    Template Name:       <xsl:value-of select="@Name" />         
</B>
       <BR/><BR/>

       <xsl:choose>
              <xsl:when
test="./Queries/DataQuery/Abstract/Columns|Rows/Groups/Group/Dimensions/Dimen
sion[count(*) = 0]">

                     <TABLE BORDER="1"  width="85%" >
                           <TR   BGCOLOR="D3D3D3" >
                                  <TD width="65%">     <xsl:text>Dimension
Name</xsl:text>             </TD>
                                  <TD>                 <xsl:text>Column Group
Name</xsl:text>   </TD>
                           </TR>
                     </TABLE>

                     </xsl:when>
       </xsl:choose>

</xsl:template>




<xsl:template match="Dimension">
                    
                     <xsl:for-each select=".">
                           <TR   BGCOLOR="D3D3D3" >
                                  <TD width="65%">     <xsl:value-of
select="./@Name" />        </TD>
                                  <TD>                 <xsl:value-of
select="../../@Name" />    </TD>
                           </TR>
                     </xsl:for-each>

</xsl:template>


</xsl:stylesheet>







Input:

<Template Name="Report" >
  <Queries>
    <DataQuery Name="Suppressed" >
      <Abstract>
        <Columns>
          <Groups>
            <Group Name="C02" >
              <Dimensions>
                <Dimension Name="Fiscal Year">
                </Dimension>
                <Dimension Name="Version">
                  <Conditions/>
                </Dimension>
              </Dimensions>
            </Group>
            <Group Name="C03">
              <Dimensions>
                             <Dimension Name="Fiscal Year">
                                    <Conditions/>
                             </Dimension>
                             <Dimension Name="Version">
                                    <Conditions/>
                             </Dimension>
                                  </Dimensions>
            </Group>
            <Group Name="C09">
              <Dimensions>
                <Dimension Name="Fiscal Year">
                </Dimension>
                <Dimension Name="Version">
                  <Conditions/>
                </Dimension>
              </Dimensions>
            </Group>
          </Groups>
        </Columns>
        <Rows Suppression="true">
          <Dimensions>
            <Dimension Name="Metric" />
          </Dimensions>
          <Groups>
            <Group Name="R1">
              <Dimensions>
                <Dimension Name="Metric">
                </Dimension>
              </Dimensions>
            </Group>
          </Groups>
        </Rows>
      </Abstract>
    </DataQuery>
  </Queries>
</Template>





Output:


Template Name: Report
Dimension Name
Column Group Name
Fiscal Year C02 Fiscal Year C09 Metric R1

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.