Subject: Re: [xsl] Creating multi-level groupings From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx> Date: Mon, 30 Aug 2004 07:04:35 -0700 (PDT) |
I hope the following XSL would help .. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" indent="yes"/> <xsl:key name="by-prod_doctype_cust" match="doc" use="concat(normalize-space(../text()), ' ' , doc_type, ' ', customer)"/> <xsl:template match="/"> <html> <head> <title/> </head> <body> <table border="1"> <xsl:for-each select="volume/product/doc[count(. | key('by-prod_doctype_cust', concat(normalize-space(../text()), ' ' , doc_type, ' ', customer))[1]) = 1]"> <tr> <td> <xsl:value-of select="normalize-space(../text())"/> </td> <td> <xsl:value-of select="doc_type"/> </td> <td> <xsl:value-of select="customer"/> </td> </tr> <xsl:for-each select="key('by-prod_doctype_cust', concat(normalize-space(../text()), ' ' , doc_type, ' ', customer))"> <tr> <td/> <td> <xsl:value-of select="id"/> </td> <td> <xsl:value-of select="title"/> </td> </tr> </xsl:for-each> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> Regards, Mukul --- "Jones, Christopher Thorman (Chris)" <ctj@xxxxxxxxxx> wrote: > I am trying to create a HTTP table using the > following data, however, I want it grouped on > multiple fields (namely "product", "doc_type" & > "customer"). > > I've manage to group on one field (see bottom of > mail) but can't find info on extending this to more > than one key. > > > --------------------------Start of XML > ------------------------------------------ > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet type="text/xsl" > href="VitalVolumes4.xsl"?> > <!-- Vital Document Volumes Database --> > <volume> > <product>01 Vital ABC > <doc> > <doc_type>02 External Reqs</doc_type> > <customer>Government</customer> > <id>3246.01.02.01.01</id> > <title>Specification Document for the FR > trial</title> > </doc> > <doc> > <doc_type>02 External Reqs</doc_type> > <customer>NASA</customer> > <id>3246.01.02.02.01</id> > <title>Placeholder for T-Mobile Doc</title> > </doc> > </product> > <product>02 Vital XYZ > <doc> > <doc_type>01 Type</doc_type> > <customer>Customer A</customer> > <id>3246.02.01.01.01</id> > <title>CSD for Customer A - Vital XYZ</title> > </doc> > <doc> > <doc_type>05 Another Type</doc_type> > <customer>Customer B</customer> > <id>3246.02.05.01.01</id> > <title>Some other document</title> > </doc> > </product> > </volume> > ----------------End of > XML----------------------------------- > > ----------------Start of > XSL-------------------------------- > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:key name="docs_by_doc_type" match="doc" > use="doc_type"/> > .. > .. > <xsl:for-each select="doc[count(. | > key('docs_by_doc_type', doc_type)[1]) = 1]"> > <xsl:sort select="doc_type"/> > <tr> > <td colspan="4"> > <xsl:value-of select="doc_type"/> > </td> > </tr> > <xsl:for-each select="key('docs_by_doc_type', > doc_type)"> > <xsl:sort select="id"/> > <tr> > <td/> > <td> > <xsl:value-of select="id"/> > ... > . > . > . > ----------------End of > XSL----------------------------------- __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Creating multi-level grouping, Jones, Christopher T | Thread | Re: [xsl] sorting titles w stopword, Susan Campbell |
[xsl] FOX: How to generate bookmark, Kenny Bogoe (BogoeMD | Date | RE: [xsl] XSL/XSLT Cross-Browser pr, karl |
Month |