Subject: [xsl] group-by sorting and paging problem... From: Robert Wilkins <wilkins.robert@xxxxxxxxxxx> Date: Fri, 24 Nov 2006 21:19:13 -0500 |
I've been struggling with this for days. The problem seems simple, but I've had no luck...Here's what I'm trying to do:
- Group the <msgblocks> by attribute 'id' - Use the current grouping id (@id) to sort the data - Arrange the data I want to extract from each sorted <msgblock> (errnum and message) into a series of balanced 4 column tables limited to a maximum of x number of rows, based on the value of the global param $cols - Write (or page) each table to a result-document
<messages> <msgblock id="2000"> <msg-num>0</msg-num> <errnum>2000</errnum> <message> No message</message> </msgblock>
<msgblock id="2001"> <msg-num>100</msg-num> <errnum>2001</errnum> <message> "Row not found"</message> </msgblock>
<msgblock id="2002"> <msg-num>101</msg-num> <errnum>2002</errnum> <message> "Value truncated"</message> </msgblock>
<msgblock id="2003"> <msg-num>102</msg-num> <errnum>2003</errnum> <message> "Using temporary table"</message> </msgblock>
<msgblock id="2004"> <msg-num>103</msg-num> <errnum>2004</errnum> <message> "Invalid data conversion"</message> </msgblock>
<msgblock id="2559"> <msg-num>130</msg-num> <errnum>2559</errnum> <message> "A row could not be converted to the new schema format"</message> </msgblock>
<msgblock id="2532"> <msg-num>124</msg-num> <errnum>2532</errnum> <message> "Invalid data conversion: NULL was inserted for column '%1' on line %2."</message> </msgblock>
<msgblock id="2005"> <msg-num>104</msg-num> <errnum>2005</errnum> <message> "Row has been updated since last time read"</message> </msgblock>
<msgblock id="2006"> <msg-num>105</msg-num> <errnum>2006</errnum> <message> "Procedure has completed"</message> </msgblock>
<msgblock id="2007"> <msg-num>106</msg-num> <errnum>2007</errnum> <message> "Value for column '%1' in table '%2' has changed"</ message> </msgblock>
<msgblock id="2008"> <msg-num>111</msg-num> <errnum>2008</errnum> <message> "Statement cannot be executed"</message> </msgblock>
<msgblock id="2530"> <msg-num>123</msg-num> <errnum>2530</errnum> <message> "Database created without any schema"</message> </msgblock>
<msgblock id="2009"> <msg-num>200</msg-num> <errnum>2009</errnum> <message> "Warning"</message> </msgblock>
<msgblock id="2011"> <msg-num>80</msg-num> <errnum>2011</errnum> <message> "Unable to start database server"</message> </msgblock>
<msgblock id="2702"> <msg-num>1033</msg-num> <errnum>2702</errnum> <message> "Unable to start database server: Server fatal error"</ message> </msgblock>
<msgblock id="2012"> <msg-num>81</msg-num> <errnum>2012</errnum> <message> "Invalid database server command line"</message> </msgblock>
Grouping and sorting the <msgblock> nodes is necessary because the @id's are not always in the right sequence. I can group and sort them properly with this snippet:
<xsl:for-each-group select="msgblock" group-by="@id"> <xsl:sort select="current-grouping-key()"/> <for-each select=current-group()/> <xsl:value-of select =errnum/> <xsl:vale-of select=message/> </for each> <for-each-group>
I can limit the number of table items by testing the global parameters $start-index (1) and $group-size (40) with something like this:
<xsl:if test="position() >= $start-index and position() <= $group-size"> . . . </xsl:if>
I can see the logic in Micheal Kay's examples (town-by-columns, town- by-rows, towns-sorted-by-rows) in the XSLT 2.0 Programmer's Reference. But I can't seem to put them all together. (I always seem to end up dividing by zero). I seemed close a couple of times, but I've had no luck. In fact, I seem to be going backwards.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Transform inline-block ty, Christian Roth | Thread | [xsl] counting nodes question, Philip Vallone |
Re: [xsl] Standards checkers for XS, Dimitre Novatchev | Date | Re: [xsl] Standards checkers for XS, Colin Paul Adams |
Month |