|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Converting a SQL XML Resultset using XSL...
I was really interested in an XSL solution which you have so appropriately provided. Thank you both very much for your suggestions. The XSL Joerg provided worked beautifully. I'm starting to better understand grouping in XSL. Thanks again, Aaron > -----Original Message----- > From: Joerg Heinicke [mailto:joerg.heinicke@xxxxxx] > Sent: Thursday, February 28, 2002 1:53 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: Converting a SQL XML Resultset using XSL... > > > Hello Aaron, > > if you don't want the SQL-solution or can not use it, here is the > XSLT-solution: > > Your problem is a grouping problem. Some information you can > find here: > http://www.jenitennison.com/xslt/grouping/index.xml. In your > case you need a > multiple level grouping, first by id, second by tag_name. Using the > Muenchian Method you need for this at first the id and at second a > concatenated string with id and tag_name: > > <?xml version="1.0" encoding="ISO-8859-1"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" > indent="yes"/> > > <xsl:key name="rows1" match="row" use="id"/> > <xsl:key name="rows2" match="row" use="concat(id,'::',tag_name)"/> > > <xsl:template match="page"> > <xsl:copy> > <xsl:apply-templates select="rowset/row[count( . | > key('rows1', > id)[1] ) = 1]" mode="rows1"/> > </xsl:copy> > </xsl:template> > > <xsl:template match="row" mode="rows1"> > <individual id="{id}" name="{display_name}"> > <xsl:apply-templates select="key('rows1',id)[count( . > | key('rows2', > concat(id,'::',tag_name))[1] ) = 1]" mode="rows2"/> > </individual> > </xsl:template> > > <xsl:template match="row" mode="rows2"> > <tag name="{tag_name}"> > <xsl:apply-templates select="key('rows2', > concat(id,'::',tag_name))"/> > </tag> > </xsl:template> > > <xsl:template match="row"> > <tmp name="{tmp_name}" score="{score}"/> > </xsl:template> > > </xsl:stylesheet> > > Hope this helps. But maybe it's better to use the > SQL-solution provided by > Kirk. > > Regards, > > Joerg > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > 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








