Help - use XSLT to group by multiple values?

I'm using XSLT and .NET Framework 1.1 to try to transform XML to group
by multiple values, and I'm not succeeding.  I have source XML that
looks like the following:

<Data>
	<Flavor>
		<Name>Vanilla</Name>
		<StartDate>20070704</StartDate>
		<EndDate>20071231</EndDate>
	</Flavor>
	<Flavor>
		<Name>Chocolate</Name>
		<StartDate>20070704</StartDate>
		<EndDate>20071131</EndDate>
	</Flavor>
	<Flavor>
		<Name>Strawberry</Name>
		<StartDate>20070804</StartDate>
		<EndDate>20071131</EndDate>
	</Flavor>
	<Flavor>
		<Name>Mint</Name>
		<StartDate>20070704</StartDate>
		<EndDate>20071131</EndDate>
	</Flavor>
</Data>


I need to group the items together that have the same values for
StartDate and EndDate such that the output looks like the following:

<Groups>
	<Group>
		<Name>Group1</Name>
		<Flavors>
			<Name>Vanilla</Name>
		</Flavors>
		<StartDate>20070704</StartDate>
		<EndDate>20071231</EndDate>
	</Group>
	<Group>
		<Name>Group2</Name>
		<Flavors>
			<Name>Chocolate</Name>
			<Name>Mint</Name>
		</Flavors>
		<StartDate>20070704</StartDate>
		<EndDate>20071131</EndDate>
	</Group>
	<Group>
		<Name>Group3</Name>
		<Flavors>
			<Name>Strawberry</Name>
		</Flavors>
		<StartDate>20070804</StartDate>
		<EndDate>20071231</EndDate>
	</Group2>
</Groups>

I've tried to use the Muenchian Method with keys, but I haven't been
successful. Can anyone please provide some assistance?

Thanks in advance

0
n.phelge (1)
7/23/2007 2:40:47 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
669 Views

Similar Articles

[PageSpeed] 5

n.phelge wrote:

> I've tried to use the Muenchian Method with keys, but I haven't been
> successful. Can anyone please provide some assistance?

Not sure where you had problems as you have not shown your XSLT but here 
is a working XSLT 1.0 stylesheet:

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:strip-space elements="*"/>

   <xsl:key name="by-date" match="Flavor" use="concat(StartDate, '_', 
EndDate)"/>

   <xsl:template match="Data">
     <Groups>
       <xsl:apply-templates select="Flavor[generate-id() = 
generate-id(key('by-date', concat(StartDate, '_', EndDate))[1])]" 
mode="group"/>
     </Groups>
   </xsl:template>

   <xsl:template match="Flavor" mode="group">
     <Group>
       <Name><xsl:value-of select="concat('Group', position())"/></Name>
       <Flavors>
         <xsl:apply-templates select="key('by-date', concat(StartDate, 
'_', EndDate))/Name"/>
       </Flavors>
       <xsl:apply-templates select="StartDate | EndDate"/>
     </Group>
   </xsl:template>

   <xsl:template match="Name | StartDate | EndDate">
     <xsl:copy>
       <xsl:apply-templates/>
     </xsl:copy>
   </xsl:template>

</xsl:stylesheet>
-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
0
mahotrash (1777)
7/23/2007 3:35:03 PM
Reply:

Similar Artilces:

Export or Print multiple reports from one Access Report by Group
I have a sales report that is grouped by Salesperson. Each salesperson has multiple pages of the report and I need to either print it or export it to PDF as individual reports for each salesperson. Is there a way to export/print the report into seperate reports for each Salesperson? Thanks. I am pretty new to Access, but I have figured out how to get the report in the structure I want it. I just can't get the information out of the program in the format. I can print as one PDF document and then go and cut that up in Adobe, but I wanted to see if Access could do it for me and save ...

Drag and drop on a recycle bin ... a little help needed
Hello all I have implemented the drag and drop code from The Code project http://www.codeproject.com/shell/explorerdragdrop.asp?msg=420048 but it crashes when the files are dropped on the recycle bin. CCmdTarget::~CCmdTarget() { #ifndef _AFX_NO_OLE_SUPPORT if (m_xDispatch.m_vtbl != 0) ((COleDispatchImpl*)&m_xDispatch)->Disconnect(); ASSERT(m_dwRef <= 1); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE #endif #ifdef _AFXDLL m_pModuleState = NULL; #endif } Does anyone have an...

Using HTML template in 2007/Vista
Not sure if this is the right sub-forum or not.... I'm able to install an HTML page as a template using Office 2007 on an XP machine, but the same process does not work on Vista machines. The template is saved to the proper location but the problem is that when Outlook opens the form, it opens as Plain Text rather than HTML. I haven't been successful finding any solutions googling the problem - anyone here know of a fix? -- rpw ...

Trendline values #2
I used the function "LOGEST" to get an exponential fit of a series of numbers, which gives me a value of 1.0610. I also used "RSQ" function to get the R-square, which is 0.9442. Then I made a chart based on the same series of numbers and add trendline to the curve. I selected "Exponential" under "Type" and checked "Display equation on chart" and "Display R-Squared value on chart". The value shown on the chart is "y=3928.8e^0.0592x" and "R^2=0.9104". I expected to see "y=3928.8e^0.0610x" and "R^...

problem carrying over values
I have one form that has a button I''ll call it form1. The button looks at a text box for an ID and if its null it opens form2 and creates a new record in form2. If the text box is NOT null, it will go find the ID that's in the text box and filter it in form2. When the new record is created in form2, I need the ID to be put into the NULL text box in form1. I know how to do this however, if you open form2 on its own, then the error msg comes up that it can't find form1. I know why I'm getting this error, but don't know the fix for it. Is there a work around? Thanks...

How to use wincrypt.h?
Hi: I use it in a console app. I do this: The first I don't include .h file. Then add #define _WIN32_WINNT 0x0400 and #include <wincrypt.h> in the stdafx.h. compile ... error: error C2146: syntax error : missing ';' before identifier 'HRESULT' fatal error C1004: unexpected end of file found How to do? thanks! >error C2146: syntax error : missing ';' before identifier 'HRESULT' >fatal error C1004: unexpected end of file found > >How to do? Try adding #include <windows.h> before. Dave Thank you. "David Lowndes" ...

Exchange/Outlook 2003
In an effort to make sure we never reach the 16GB threshold for the SBS 2003 Exchange Info Store, I'm looking to setup a GPO to give everyone consistent AutoArchive settings as well as a common location for the PST file. I have already downloaded the Office Administrative Templates for Outlook 2003, so I already have found the settings I want to modify and have made the changes, I just haven't made them live on the domain yet. My thoughts to date: * create two GPOs, one for the PST location, one for the autoarchive settings themselves * set PST location to local drive, or common netw...

insert password using vb
I have multi worksheets in a template with formulas. I can hide th formulas but if I add a password, my macros stop and ask for th password when the macro is in a protected worksheet. Is there a way o adding the password to a macro so that the macro will run smoothl without stopping and asking for a manual insertion of the password? Thanks Do -- abbevill ----------------------------------------------------------------------- abbeville's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=976 View this thread: http://www.excelforum.com/showthread.php?threadid=26122 ...

Exchange 2003
Howdy: We ahve recently migrated from an existing WinNT4/Exchange 5.5 Installation to a new Win2k3/Exchange 2003 mixed mode installation. All went well with the first server install but I am having problems installing the second and getting it to accept mail probably due to the reasonably complex computing environment. In short: All external mail is first handled via one of six UNIX servesr which does a look up and forwards the mail to the appropriate server in the format user@server.domain.com. This worked well enough with a single server, for the average Exchange customer the UNIX would...

same subform used in two different forms
Hi Folks, Is it possible to use the same subform in two different main forms simultaneously? If it's possible, is it good practice? I can foresee that there may be problems with code, but the subform I'm thinking of is very basic. Three tables: tblFamily FamID (primary key) FamLastName tblIndividual IndID (primary key) InFamID FirstName MiddleName ....other personal data tblAddress AddressID AdFamID street city state zip Two main forms for different types of data entry frmFamily with family information on the main form and address information...

XML TreeNode.Parent property when using 2.0 TreeView?
How do I get a TreeNode.Parent property when using the 2.0 TreeView control? When the data source is an XML file there may be redundant names in the tree. For example, when a child node with the value of 'name' is selected I don't have a clue how to get the name of its parent which may be 'person' or 'school.' <%= Clinton Gallagher "clintonG" <csgallagher@REMOVETHISTEXTmetromilwaukee.com> wrote in message news:%23erL6WOXFHA.3532@TK2MSFTNGP10.phx.gbl... > How do I get a TreeNode.Parent property when using the 2.0 TreeView > control? &...

cut/copy and paste forumla problem help
i am currently using the correlation formula to test on a large set of data: e.g. CORREL(IGR!C233:C262,IIA!C233:C262) IGR and IIA - they are a pair of data i place in 2 different worksheets, each has set of data, and I need to pull the data of C233 and C262 in IGR and IIA worksheet and I have many pairs in different worksheets E.G. RMR and RHR so I copy the forumla above and hope can only manually adjust the symbol from IGR and IIA to RMR and RHR when I copy it shift the number down =CORREL(IGR!C242:[/B]C271,IIA!C242:C271) from C233 to C242 and C 262 to C271 and I would have to ma...

#VALUE! error
I'm sorry but I added to this formula and it started with the #VALUE! again. The error goes away once I enter data. It's just so tacky looking seeing all these error messages. Please help! =IF(OR(B3="",D3="",B3>D3),"",'Tank Sizes'!$F$15)*(2/98)*F3/D3 You have your closing parenthesis for the IF function right after the "$F$15 reference which means the division by D3 is not controlled by the IF function's testing for D3="". I think moving the parenthesis to the end of the calculation will yield the result you want... =IF(O...

Values in the Legend?
Is there a way to show values in the legend - behind the series text? Thanks, Phil Do you want to show just a single value? You can either build a lengthier label (like =A1&B1), and use this as the new series name, or you can select multiple cells for the name, and Excel puts them together with a space between. - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ Phil Hageman wrote: > Is there a way to show values in the legend - behind the series text? > Thanks, Phil ...

Only Display records before and after a change in teh value of a f
I have a table that looks like the following RUNID | DATETIME | PROCESS 0001 1/1/09 1201 Neck 0001 1/1/09 1202 Neck 0001 1/1/09 1203 Neck 0001 1/1/09 1204 Neck 0001 1/1/09 1205 Neck 0001 1/1/09 1206 Body 0001 1/1/09 1207 Body 0001 1/1/09 1208 Body 0001 1/1/09 1209 Body 0001 1/1/09 1210 Neck 0001 1/1/09 1211 Neck 0001 1/1/09 1212 Neck 0001 1/1/09 1213 Neck 0001 1/1/09 1214 Body 0001 1/1/09 1215 Body 0001 ...

Not even Office Live Using Document Connection
> This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --B_3331376369_11931625 Content-type: text/plain; charset="ISO-8859-1" Content-transfer-encoding: 8bit While others are saying they can use the SP2 version of Document Connection to Office Live but not Sharepoint I can�t even get connected to my Office Live Workspace which I have been using via the browser for a long time. I can't add my Office LIve Workspace location to Document Connection. The gear just spins and what�s almost as bad it...

Min and Max values for different salespeople?
Hi there, I am trying to find the minimum and maximum sales for each salesperson. I can not sort by salesperson -- I must sort by sales date. How do I do this? 1/2/1999 Bob $7 1/5/1999 Rick $20 1/7/1999 Sue $75 1/10/1999 Bob $5 1/15/1999 Sue $3 1/27/1999 Rick $53 So, I need to know Bob's minimum sale was $5, and his maximum sale was $7. I know how to use the MIN and MAX functions, but how do I tie in the sales person name? Assume your salesperson names are in column B and their corresponding sale amount is in column C: =MAX(IF(B1:B10="Bob&...

Delegate multiple calendars for Manager
Question Hi - I need to delegate the calendars for 12 department members to my manager. Is there any way to do this, other than on a user-by-user basis? Thank you Hi, You can set calendar permissions using pfdavadmin (can be found on MS web). Leif "TheITDude" <TheITDude@discussions.microsoft.com> wrote in message news:D276128F-1639-4AA9-9B05-5ABB1663433A@microsoft.com... > Question > Hi - I need to delegate the calendars for 12 department members to my > manager. Is there any way to do this, other than on a user-by-user basis? > > Thank you ...

Please Help strange problem
Hope someone can help with this after downloading a small excel file from a dealer site that is a genereated report, I can download it as an excel file, upon doing so and pasting it into my working sheet I end up with this � with the two dots above it at the end of the text in every cell, and when it is removed some cells change for example a cell which has a long number for a serial number will shorten as well where do I start the excel version is 2000 blacklabhfxnospam@hotmail.com remove no spam ...

help #10
every time i try to send something through outlook I get an error 0x800CCCC0D Do you have any more details about the error? Also, which version of Outlook are you using? "tina" <tinaatweb22@yahoo.com> wrote in message news:081001c365f2$cc7bc3e0$a301280a@phx.gbl... > every time i try to send something through outlook I get > an error 0x800CCCC0D ...

Query related to Help button in Property sheets?
Hi In my application for showing a wizard, i m using Property Sheets(tab dialog boxes derived from CPropertyPage). I have 4 buttons on my wizard: Back, Next, Cancel & Help. My problem is that how do i implement the <Help> button. I have to open a .chm file as soon as the user clicks the <Help> button. But where do i write the code as there is no handler function in the class wizard for Help button. Handler functions for Back,Next & Finish is there? How do i implement the Help button? Waiting for suggestions Regards ...

Don't chart X-axis without values.
On a line chart I am plotting two individual columns and then SUM(ming) these two for a total. Future dates of the individual columns have no data BUT the formula for SUM(ming) the two results in zero (0) which is plotted on my chart. I've tried a number of approches to the formula, blank (""), and Null (which results in a string and causes an error. How can I leave my formula in the future dates and not effect my chart. Obviously, with moving from 300k to zero in one week is scary. Thanks, Hank Hank - Excel can't return a NULL or BLANK from a function (not t...

formulas when there may/may not be a value
What formula do you use when there may not be a value there? Like: ITEM QTY SOLD T0887 50 1 T0887 100 T0887 200 2 T0992 50 3 T0992 100 To get: # of sold items for each item? -- Nicki Taylor =SUMIF(A:A,"T0887",C:C) -- HTH RP (remove nothere from the email address if mailing direct) "NTaylor" <NTaylor@discussions.microsoft.com> wrote in message news:6E22EEF1-44E5-4C5B-AFBD-B8053172702F@microsoft.com... > What formula do you use when there may not be a value there? Like: > > ITEM QTY SOLD > T0887 50...

Help Sorting Data
I have the following columns of information and need to setup a formula that will give me the total by location, by dept, then by g/l account. DEPT G/L Account Bakersfield Fleet 42101 $10.00 Fleet 42101 $125.00 S & D 42101 $35.00 MEM 42199 $10.00 Fleet 23099 $1,000.00 I will then point to the cell containing the final cost number. Example: Bakersfield, Department Fleet, G/L Account 42101 $1,145 Look at the Subtotal function, or a Pivot Table. Regards, Fred "dh1069"...

Prefill Multiple Macro Buttons
I created a template and created multiple macro buttons where the user can click and type the appropriate information. There are several macro buttons that are the same and the user would have to key the information in several times. For example: [Click and type company name]. Is there a way to have the user type the company name once in that macro buttun and it prefills all the macro buttons that have [Click and type company name]? Thanks! Jlo See http://gregmaxey.mvps.org/Repeating_Data.htm -- <>>< ><<> ><<> <>>< ><...