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

Re: Using XSL to Translate Repetitive-Node XML to Tabl

Subject: Re: Using XSL to Translate Repetitive-Node XML to Table with COLSPANs
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 12 Feb 2004 17:30:52 -0500
xsl translate
Hi Leo,

At 03:49 PM 2/12/2004, you wrote:
                        <data columnid="01" name="Feb"/>
                        <data columnid="11" name="Feb"/>
                        <data columnid="21" name="Feb"/>
                        <data columnid="31" name="Feb"/>
                        <data columnid="41" name="Y-T-D(Feb)"/>
                        <data columnid="51" name="Y-T-D(Feb)"/>
                        <data columnid="61" name="Y-T-D(Feb)"/>
                        <data columnid="71" name="Y-T-D(Feb)"/>

How easy this is depends largely on constraints on your data.


If you can be certain that data elements to be grouped in a cell not only share a @name value, but also are the only ones that have that @name value, it's not so hard:

<xsl:template match="data">
<xsl:variable name="thisname" select="@name"/>
<!-- first be sure we emit cells only for the first data element
with a given name -->
<xsl:if test="not($thisname = preceding-sibling::data/@name)">
<!-- the colspan is the count of data children of the parent with the same name -->
<td colspan="{count(../data[@name = $thisname)}">
<xsl:apply-templates select="@name"/>
<!-- the built-in default template for attributes will emit its value -->
</td>
</xsl:if>
</xsl:template>


If however you might have a situation like

  <data columnid="01" name="Feb"/>
  <data columnid="11" name="Feb"/>
  <data columnid="21" name="Feb"/>
  <data columnid="31" name="Feb"/>
  <data columnid="41" name="Y-T-D(Feb)"/>
  <data columnid="51" name="Feb"/>

... it's harder. Considerably harder (though not impossible).

So which is it?

Cheers,
Wendell




====================================================================== 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 ======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.