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

RE: Conditionally create an html table based upon ex

Subject: RE: Conditionally create an html table based upon existance of one or two node sets
From: Rod Kane <rkane@xxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Mar 2010 14:57:25 -0400
RE:  Conditionally create an html table based upon   ex
Thanks Michael,

In this case the xml is used to construct a query and the tool that generates
the xml will leave parts of the xml empty if it cannot translate a spec.
Should have mentioned that earlier.

The objective of the template is to identify the row and/or column elements
that are missing children, so it's possible that there are missing fragments.

Rod



-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Tuesday, March 30, 2010 2:47 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Conditionally create an html table based upon existance of
one or two node sets


Although you stated the requirement as generating the table if its content
was non-empty, I reckoned that if either of the input node-sets was
non-empty then the table content would also be non-empty, so it's more
efficient and easier (and possible in XSLT 1.0) to test the input node-sets
rather than saving the output tree in a variable.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

> -----Original Message-----
> From: Rod Kane [mailto:rkane@xxxxxxxxxxxxxxxxxx]
> Sent: 30 March 2010 19:40
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Conditionally create an html table based
> upon existance of one or two node sets
>
> Thanks Wendell, have not used that before and will look into it.
>
> Thanks again,
>
> Rod
>
> -----Original Message-----
> From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
> Sent: Tuesday, March 30, 2010 2:38 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Conditionally create an html table based
> upon existance of one or two node sets
>
> Rod,
>
> At 02:02 PM 3/30/2010, you wrote:
> >I need to create a table if either the second and third
> >"apply-template"  directives return nodes, and otherwise
> create nothing .
>
> Bind them to a variable so:
>
> <xsl:variable name="results">
>    <xsl:apply-templates .../>
>    <xsl:apply-templates .../>
> </xsl:variable>
>
> then generate your table if $results has any content.
>
> In XSLT 1.0 the easiest way is to test for non-whitespace text:
>
> <xsl:if test="normalize-space($results)">
>    <table border="1"  width="85%" >
>      <xsl:copy-of select=$results"/>
>    </table>
> </xsl:if>
>
> In XSLT 2.0 you can be smarter about what's inside $results.
>
> You can also split $results into two variables if you need to
> handle the two apply-templates results separately.
>
> Good luck,
> Wendell
>
>
> >  "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/Gr
> oup/Dimens
> >ions/Dimension[count(*)
> > = 0]"/>
> >        <xsl:apply-templates
> >
> >select="Template/Queries/DataQuery/Abstract/Rows/Groups/Group
> /Dimension
> >s/Dimension[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/Dimension
> > s/Dimension[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>
> >
>
>
> ======================================================================
> Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc.                http://www.mulberrytech.com
> 17 West Jefferson Street                    Direct Phone: 301/315-9635
> Suite 207                                          Phone: 301/315-9631
> Rockville, MD  20850                                 Fax: 301/315-8285
> ----------------------------------------------------------------------
>    Mulberry Technologies: A Consultancy Specializing in SGML
> and XML
> ======================================================================

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.