[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: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 12 Feb 2004 22:35:52 GMT
counter using xsl

> 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

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.