[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
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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|