[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] XML grouping/sorting question - displaying a matrix
I'm fairly new to XSL, but have been finding the great XSL resources out there a great help. Specifically, I have spent some time going through the various materials on Jeni Tennison's web site, most recently dealing with grouping and sorting (http://www.jenitennison.com/xslt/grouping/muenchian.html). I have a sample data set (trimmed down for simplicity) which looks like this: <records> <record> <id>0001</id> <test id="0001"> <title>Mr</title> <forename>John</forename> <name>X</name> </test> <test id="0002"> <title>Dr</title> <forename>Amy</forename> <name>B</name> </test> </record> <record> <id>0002</id> <test id="0003"> <title>Mr</title> <forename>Tim</forename> <name>Y</name> </test> <test id="0004"> <title>Dr</title> <forename>Kevin</forename> <name>X</name> </test> </record> ... </records> and am processing it using XSL in the following way: <xsl:template match="records"> <html> <body> <table> <xsl:for-each select="recod/test[count(. | key('test-by-name', name)[1]) = 1]"> <tr><td><xsl:value-of select="name" />|<xsl:value-of select="name()" /></td></tr> </xsl:for-each> <tr> <td>ID</td> <xsl:for-each select="record/test[count(. | key('test-by-name', name)[1]) = 1]"> <td><xsl:value-of select="name" /></td> </xsl:for-each> </tr> <xsl:for-each select="record"> <tr> <td><xsl:value-of select="id" /></td> <xsl:for-each select="test[count(. | key('test-by-name', name)[1]) = 1]"> <td><xsl:value-of select="name" /></td> </xsl:for-each> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> I am able to get the list of unique tests for all records, but ultimately I would like a way to produce a matrix similar to the following: ID X B Y C 0001 * * 0002 * * 0003 * * 0004 * * Is there a way to match each record/test node with the position in the key value and generate a matrix? Finally, I would ultimately like to sort the columns in the above matrix by element count so that the elements which appear most are in the first columns, though I haven't found a way to do this: ID X C B Y 0001 * * 0002 * * 0003 * * 0004 * * Any help would be appreciated, even if it's - "Sry this isn't possible with XSLT 1.0". Thanks, Kevin
|
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
|