Subject: RE: [xsl] Grouping in XSL From: "Amuchastegui, Maria" <Maria.Amuchastegui@xxxxxxxxxxx> Date: Tue, 27 Jan 2004 09:28:28 -0500 |
You're right. That was a typo. -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Josh Canfield Sent: January 26, 2004 3:46 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Grouping in XSL I'd just like to comment on the usage of // in the match. I haven't read the whole template, but looking at the XML I'm pretty sure you want to match /cmsParent/node... and not //cmsParent/node... since cmsParent is the document element, and there don't appear to be any embedded cmsParent nodes that you want to match. // is short for /descendant-or-self::node()/ Josh -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Amuchastegui, Maria Sent: Monday, January 26, 2004 11:49 AM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] Grouping in XSL Correction: <xsl:template match="//cmsParent/node/actv/dimensions/*[name() = 'comp']/@prodLongDesc"> <tr> <td><xsl:value-of select="."/></td> <td><xsl:value-of select="../../mthCost"/></td> <td><xsl:value-of select="../../ytdCost"/></td> </tr> </xsl:template> -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Amuchastegui, Maria Sent: January 26, 2004 2:23 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] Grouping in XSL Try this. - Maria <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="ISO-8859-1" indent="yes"/> <xsl:template match="/"> <html> <head> <title/> </head> <body> <h1>actvShortDesc: <xsl:value-of select="/cmsParent/node/actv/@actvLongDesc"/> </h1> <xsl:apply-templates select="/cmsParent/node/actv/dimensions[1]/*"/> </body> </html> </xsl:template> <xsl:template match="/cmsParent/node/actv/dimensions[1]/*[(name() != 'mthCost') and (name() != 'ytdCost')]"> <table border="1"> <tbody> <tr> <th> <xsl:choose> <xsl:when test="name() = 'prod'">Product</xsl:when> <xsl:when test="name() = 'cust'">Customer</xsl:when> <xsl:when test="name() = 'chan'">Channel</xsl:when> <xsl:when test="name() = 'comp'">Company</xsl:when> </xsl:choose> </th> <th>Current Month</th> <th>Year to Date</th> </tr> <xsl:choose> <xsl:when test="/cmsParent/node/actv/dimensions/*/@prodLongDesc = following-sibling::*/@prodLongDesc"> <tr> <td> <xsl:value-of select="@prodLongDesc"/> </td> <td> <xsl:value-of select="sum(//mthCost)"/> </td> <td> <xsl:value-of select="sum(//ytdCost)"/> </td> </tr> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="//cmsParent/node/actv/dimensions/*[name() = 'comp']/@prodLongDesc"/> </xsl:otherwise> </xsl:choose> </tbody> </table> <br/> <br/> </xsl:template> <xsl:template match="//cmsParent/node/actv/dimensions/*[name() = 'comp']/@prodLongDesc"> <tr> <td> <xsl:value-of select="."/> </td> <td> <xsl:value-of select="/cmsParent/node/actv/dimensions/mthCost"/> </td> <td> <xsl:value-of select="/cmsParent/node/actv/dimensions/ytdCost"/> </td> </tr> </xsl:template> <xsl:template match="mthCost | ytdCost"/> </xsl:stylesheet> -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of GORDIST@xxxxxxxxxxxxxx Sent: January 26, 2004 10:41 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Grouping in XSL I have only been using XSL for the past few months and am having trouble trying to group certain elements or attributes together while at the same time summing up their values. Here is a sample of the XML that we are using: <cmsParent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" parentShortDesc="FIN_INFO_SERVICES" parentLongDesc="Financial Information Services"> <node nodeShortDesc="001010" nodeLongDesc="Annual Meeting" partitionKey ="CST200304200304A001ECORP" costDom="ECORP" from_dt="2003-04-01" adjdate="" adjindic="N"> <actv actvShortDesc="PERFORM STRAT INIT" actvLongDesc="Perform Strategic Initiatives"> <dimensions> <prod prodShortDesc="xyz" prodLongDesc="XYZ Corporation" /> <cust prodShortDesc="abc" prodLongDesc="ABC Corporation" /> <chan prodShortDesc="zzz" prodLongDesc="ZZZ Corporation" /> <comp prodShortDesc="003" prodLongDesc="Nationwide Property" /> <mthCost>500.00</mthCost> <ytdCost>1000.00</ytdCost> </dimensions> <dimensions> <prod prodShortDesc="xyz" prodLongDesc="XYZ Corporation" /> <cust prodShortDesc="abc" prodLongDesc="ABC Corporation" /> <chan prodShortDesc="zzz" prodLongDesc="ZZZ Corporation" /> <comp prodShortDesc="002" prodLongDesc="Nationwide Life" /> <mthCost>1000.00</mthCost> <ytdCost>2000.00</ytdCost> </dimensions> </actv> </node> </cmsParent> The output needs to look like this: actvShortDesc: Perform Strategic Initiatives Product Current Month Year to Date XYZ Corporation 1500.00 3000.00 Customer Current Month Year to Date ABC Corporation 1500.00 3000.00 Channel Current Month Year to Date ZZZ Corporation 1500.00 3000.00 Company Current Month Year to Date Nationwide Property 500.00 1000.00 Nationwide Life 1000.00 2000.00 Any help would be much appreciated on this topic. Thanks, Todd Gordish XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Grouping in XSL, Josh Canfield | Thread | [no subject], Andrew Welch |
[xsl] RE: www.UDEF.org, Ed Dodds | Date | Re: [xsl] XSLT + SAX., Mike Haarman |
Month |