Subject: Re: [xsl] spreadsheet xml and group-starting-with From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx> Date: Thu, 07 Apr 2011 02:39:28 +0200 |
I have a MS spreadsheet xml that I will be transforming into an html table. I need to use group-starting-with to group multiple rows into one based on empty cells in the first column.
ex. If I have
Col A, Col b, Col c 1a, 1b, 1c , 2b, 2c , ,3c 4a,4b,4c , ,5c --- I will eventually create a html table with two rows and three columns. For now I am trying to just get grouping to work, but I got stuck. Just when I thought I had for-each-group figured out I get stumped again. Can you get me going in the right direction?
My xslt --------------------------------------------------------------------- <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"> <xsl:output encoding="iso-8859-1" method="xml" indent="yes"/>
<xsl:template match="ss:Workbook"> <body> <xsl:apply-templates select="ss:Worksheet[1]/ss:Table"/> </body> </xsl:template>
<xsl:template match="ss:Table"> <xsl:for-each select="ss:Row"> <xsl:if test="ss:Cell[1][not(@ss:Index)]"><data>grouping row</data></xsl:if> </xsl:for-each> <data>show them grouped now</data> <xsl:for-each-group select="ss:Row" group-starting-with="ss:Cell[1][not(@ss:Index)]">
<group> <xsl:copy-of select="current-group()"/> </group> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> --------------------------------------------------------------------- End My xslt
For this example, I want output that looks something like the following. It doesn't have to be exact, but if I can get two groups with the implied cell data, then I can probably go from there, I hope. ---------------------------------------------
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:saxon="http://saxon.sf.net/" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html4="http://www.w3.org/TR/REC-html40" xmlns:html="http://www.w3.org/1999/xhtml" exclude-result-prefixes="saxon xs o x ss html4 html" >
<xsl:template match="/"> <xsl:apply-templates select="ss:Workbook/ss:Worksheet[1]/ss:Table"/> </xsl:template>
<xsl:template match="ss:Workbook"> <body> <xsl:apply-templates select="ss:Worksheet[1]/ss:Table"/> </body> </xsl:template>
-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx, http://www.le-tex.de
Registergericht / Commercial Register: Amtsgericht Leipzig Registernummer / Registration Number: HRB 24930
Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek, Thomas Schmidt, Dr. Reinhard Vvckler
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] spreadsheet xml and group-sta, Fred Christian | Thread | Re: [xsl] spreadsheet xml and group, Fred Christian |
[xsl] spreadsheet xml and group-sta, Fred Christian | Date | [xsl] Processing two documents, whi, Dave Pawson |
Month |