Subject: Re: [xsl] Conditionally create an html table based upon existance of one or two node sets From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Tue, 30 Mar 2010 14:37:45 -0400 |
I need to create a table if either the second and third "apply-template" directives return nodes, and otherwise create nothing .
<xsl:variable name="results"> <xsl:apply-templates .../> <xsl:apply-templates .../> </xsl:variable>
<xsl:if test="normalize-space($results)"> <table border="1" width="85%" > <xsl:copy-of select=$results"/> </table> </xsl:if>
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/Group/Dimensions/Dimension[count(*) = 0]"/>
<xsl:apply-templates select="Template/Queries/DataQuery/Abstract/Rows/Groups/Group/Dimensions/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/Dimensions/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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Conditionally create an h, Rod Kane | Thread | RE: [xsl] Conditionally create an h, Rod Kane |
RE: [xsl] Conditionally create an h, Rod Kane | Date | RE: [xsl] Conditionally create an h, Rod Kane |
Month |