|
[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
> Basically I'm doing grouping, which I have seen numerous postings for, but
> couldn't find anything that dealt with actual colspans and the such. My
> first idea was to use the "following-sibling::data[1]/@name = @name" test to
> keep track of how many columns to span. If the above test was false, I
> would draw the table cell using the current colspan counter. Otherwise, if
> the above test was true, then I would skip drawing the table cell and
> increment the colspan counter.
Your mind has been corrupted by exposure to limited programming
languages designed around the capabilities of a machine of the
previous century,
If you were describing what colspan means to a person, you wouldn't (I
hope) say
you start off with an imaginary variable, initialized to zero, and
then move from one column to the next, and if the value is the same,
increment this variable by one, until you get to a column that is not
followed by a column with an identical value, whereupon you use the
value as the colspan attribute.
You're more likely to say,
if you have a group of columns that use the same text, group them in
one cell and use colspan to give the size of the group of columns.
Program xslt as you would talk to a human.
You just want to use grouping (as you said) and then use count() to
return the size of the current group.
I'd use muenchian grouping for this (See jeni's site)
basically index each cell by its rowid and value:
<xsl:key name="x" match="data" use="concat(../@rowid,':',name())"/>
then
<xsl:for-each
select="data[genarate-id(.)=generate-id(key('x',concat(../@rowid,':',name())[1])]">
<!-- this is first of each group -->
<data>
<xsl:if test="key('x',concat(../@rowid,':',name()))[2]">
<xsl:attribute name="colspan"><xsl:value-of
select="count(key('x',concat(../@rowid,':',name())))"/>
</xsl:attribute>
David
--
http://www.dcarlisle.demon.co.uk/matthew
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
|

Cart








