Subject: Re: [xsl] Using XSL to Translate Repetitive-Node XML to Table with COLSPANs From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 12 Feb 2004 22:35:52 GMT |
> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using XSL to Translate Re, Wendell Piez | Thread | Re: [xsl] Using XSL to Translate Re, David Carlisle |
RE: [xsl] alternative for modes, Peter Billen | Date | Re: [xsl] Using XSL to Translate Re, David Carlisle |
Month |