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
486 Views

Similar Articles

[PageSpeed] 28

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 (1778)
7/23/2007 3:35:03 PM
Reply:

Similar Artilces:

sumifs help
I have the following formula. =SUMIFS(Table1[2],$A$11:$A$22,$A38,$B$11:$B$22,$B38) It now needs to be changed to a formula that can handle text instead of numbers. How do i do it? Use Countif instead of Sumif from =SUMIF(Table1[2],$A$11:$A$22,$A38,$B$11:$B$22,$B38) to =CountIF(Table1[2],$A$11:$A$22,$A38,$B$11:$B$22,$B38) Do you really have a function Countifs with an "S" at the end? thie maybe an UDF that needs to be modified. -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this th...

Help !
I need to create a data input screen on excel where multiple users at the same time will use them & input data. This data then needs to be stored as a database as well, where i can use it to understand trends Thank you. and the question is ...? <abrahamsaj@gmail.com> wrote in message news:1132155054.927936.191640@z14g2000cwz.googlegroups.com... >I need to create a data input screen on excel where multiple users > at the same time will use them & input data. > This data then needs to be stored as a database as well, where i can > use it to understand trends >...

Find the value of your house
To find the value of your house. Index the website and search engine to find the value of your house. You don't need to contact the realtor and appraiser . To know the value of your house just a click! http://www.geocities.com/freefreehouse/ ...

Outlook VERY slow / extra traffic while selecting multiple emails
I have purchased a new computer recently which is a 1.8GHz powerhouse with a ton of memory. The thing is that outlook crawls on this computer, while it flies on my p450. This behavior happens when i select multiple emails for any reason, ie, to delete them, move them, etc. After i am done selecting them (let go of the mouse key with a shift key multiple select)I see the network traffic going crazy, and outlook locks up until the traffic ends. It can take 5 minutes to select 100 records for instance. I have looked everywhere, but i cannot find the problem. Any ideas? I have a si...

change check box value based on combo box value
I have a form (Form1) with a combo box (Combo43) with three values: Reference 1 Antenatal 1 Quant 1 I also have two check boxes (check36 and check34) What is the best way to implement such that when Reference 1 is selected in the combo box, check34 changes from false to true, and when Antenenal 1 or quant 1 is selected, check 36 changes to true? I've tried something along the lines of, but no luck: Private Sub Combo43_AfterUpdate() If Me.Combo43 = "Reference 1" Then Me.Check32 = True Else Me.Check32 = False End If End Sub I'm a beginner at this, so any help would be ...

group memberships
Guys, In OE, you could open a contact, click on Other and see what Groups they were members of. Can you do the same in Outlook? If so, how? Thx Trumps I don't think there's a way to see all the distribution lists a contact belongs to... "Nick at Trumps" <trumps@trumps.net.au> wrote in message news:hpJxf.215088$V7.35023@news-server.bigpond.net.au... > Guys, > > In OE, you could open a contact, click on Other and see what Groups they > were members of. > Can you do the same in Outlook? If so, how? Only if using Exchange. --� Milly Staples [M...

Help with this thing
It was working in the window "Transactions >> Sales >> Transactions of Sales", but exactly were publishing a Quotation, which i wanna print, more nevertheless was shut up to me network, then I closed the window and it threw several messages to me of error, and from that then it was blocked the quotation that was working. My question is as I can unblock this document? ...

Help with Outlook Setup!!!
I have XP Professional installed and Office XP Professional. I have several users setup for kids, as well as my admin account. I want to setup a Limited Account in addition to the Admin account for myself for daily use. Am I just suppose to pick a different account name and login password and then setup my MSN Messenger and Outlook POP email with same username and password that I used to setup the Admin account? I don't need to share any contacts or anything, I just setup the admin email in order to setup Outlook. I want to input my contact info etc., into the Limited account and use ...

Moving Row Data to Column/Row Groups
First off...great forum with super smart participants. Hopefully, I ca tap into some of this brain power!! :) I have received an Excel emai spreadsheet containing hundreds of names and corresponding emai addresses. Problem is the data runs on one line from A1 to GB1. Fo example, A1 B1 C1 D1 E1 F1, etc (name 1)(email 1)(name 2)(email 2)(name 3)(email 3) etc. I need to break the data to a two column format with the first colum containing the name and the second column containing the emai address...then dropping down to the next row and listing the next set then the next and so on. The good ne...

HELP !!! I have a ARRAY Formula HELP !!!
Hello, Here is the ARRAY Formula I have and this is what I am using it for. The situation is that it worked 1 time and than not again. =INDEX(D48:K48,,MAX(IF(D48:K48<>"",COLUMN(D48:K48)))-COLUMN(D48)+1 Duty: I have a row of number that appear hourly (DOLLAR AMOUNTS), the numbe are anything from nothing to 10000. I want the hourly number to appea in specified cell. Here is an example. (I am using EXCEL 2000) Row D48:K48 answer in cell G2 1st hour D48 = $100.00 G2 Should be $100.00 2nd Hour D48 = $100.00 E48 = (nothing) G2 Should be (nothing) 3rd Hour D48 = $1...

exch 5.5 help
I am in a progress to upgrade Exchange 5.5 (on NT4) to Exhange 2k3 (on 2k3). I setup a test machine and upgrade the OS to w2k3. 1st I want to connect the 5.5 to AD, so I should install ADC. Can anyone tell me the steps? Frorestprep, domainprep, setup adc, and upgrade to exchange 2k3? If you run through the steps in the E2K3 deployment tools they will walk you through everything. -- Hope that helps. ------------------------- Jaclynn Hiranaka Enterprise Messaging Support This posting is provided "AS IS" with no warranties, and confers no rights. � 2004 Microsoft Corporation. Al...

Help with Formula Please 02-19-10
Need a Formula for the following: Data Table A B C D E F G H I 1 Tom A W 2 H 30 84 30 2 Peter A W 3 H 3 Nick B L 1 A 70 Columns F1:I3 from Data Table has break scores for each player. Below is the Result Table where I need to show a summary report for high breaks. I have no problem with Break as I use the Large function. I need a formula to insert in A1 and A2 to place the name for the corresponding breaks below. Result Table High Breaks A B Name Break 1 ...

Need help in data copying.
Hi I have an invoicing file in excel (Sheet1). I need to store the dat which is invoiced into another sheet. My Invoice Data starting from Ro 8 and column B to F (The first item is from B8-F8, second item i B9-F9). B-Item Code, C-Item Name, D-Qty, E-Price, F-Total. Once I print the invoice, I need to transfer the data to another shee (Sheet2) . When I create another invoice, the new data should be added below t the previous data in Sheet2. So that I can have all the items I sol in Sheet2. Can someone help me sending a macro for it??? I will be grateful to you. Thanks in advance Tom -...

help...help...help
I just installed Microsoft Office XP Professionaql with no problem. However, whenever I try to perform any task such as opening contacts area in order to create an entry, I receive a dialog box with Microsoft Outlook and a yellow exclamation point. Also, included in the dialog box are the words could not open the item, try again. Other information that might be important is that I use a pst file. The error message also occurs when I try to open the Contact folder from the folder list as well as when I try to perform any function. It was a clean install not an upgrade. Could you ...

Is there a way to change the return value for and ON_CONTROL() handler to return 0
I have a message map that is using the ON_CONTROL() handler. The problem is that there doesn't seem to be a ON_CONTROL_EX() or something like that that allows me to control the return value. I am handling a notification and I am doing some processing, but I need to be able to return a 0 from my handler. Without getting into using a switch statement and a ON_COMMAND() handler, is there a way to do this? Is there some function I can call within my message handler that would set the return value? -- Thanks, Bruce Who is going to see the return code? AliR. "Bruce" <...

Macro Help
Hi, I had alot of help yesterday from Jacob with the following macro, but am getting a 'run time error 13' when trying to run the macro, and i cannot see why. Any help much appreciated Sub OLApp() Dim objOL As Object, objApp As Object, lngRow As Long Set objOL = CreateObject("Outlook.Application") For lngRow = 9 To Cells(Rows.Count, "A").End(xlUp).Row If Range("E" & lngRow) = "" Then Set objApp = objOL.CreateItem(1) With objApp ..Subject = "Change Password for system" & Range("A" & lngRow)...

Multiple POP3 Domains
Hello World! I currently have Exchange 2003 up and running with Internet Mail (POP3), all is well. What I would like to do is set up another POP3 Domain on the same server. Is that possible?.. Example, current internet email: mydomain.ca add new domain email: mydomain.ca make sense?.. Hi, Yes it is possible. You need to make a new recipient policy for it. You can then choose who is going to be on the new domain or if all will be on both. This will be easiest to control via OU groups. Regards Martin "Mr Techie" <mrtechie@hotmail.com> wrote in message news:C35...

How can I copy Double-Click event behavior to multiple shapes in Visio
Hi, How can I copy the double-click event behavior to many shapes in my Visio drawing? I'd rather not have to visit the ShapeSheet for each shape and paste the formula into the EventDblClick field, since I have a lot of shapes to do this to. Is there a way to do that? Thanks, Joe Either write some VBA code to set the Dbl-Click property or try Visio's ShapeStudio that comes with the SDK kit. John... Visio MVP Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm Need VBA examples? http://www.mvps.org/visio/VBA.htm Common Visio Questions http://www.mvps.org/visio/com...

help me #2
how to restrict entering of same values or data in excel cell Hi if you mean the 'preventing of duplicate entries' you may check the following site http://www.cpearson.com/excel/NoDupEntry.htm -- Regards Frank Kabel Frankfurt, Germany mangesh khati wrote: > how to restrict entering of same values or data in excel > cell ...

Picklist values #2
Is there a way to display a chosen picklist value from the lead entity in the account entity when the lead is converted to an account? I don't want to have to maintain two picklists just to view the value after the lead is converted. You can get only value through mapping and mapping betweent two field require some validation like both field should have same datatype so if you want to get this value you have to create same picklist in account and then you can set mapping for the same "Wendy" wrote: > Is there a way to display a chosen picklist value from the lead ent...

Multiple incoming emails
Why do I get mulitples in incoming emails (5)? I've check under accounts, and only have one active. Just started 2 days ago. "momof2" <momof2@discussions.microsoft.com> wrote in message news:23BF8AB8-2620-48C8-9A30-7D750BF7A17B@microsoft.com... > Why do I get mulitples in incoming emails (5)? I've check under accounts, > and > only have one active. Just started 2 days ago. See if something here helps: http://www.howto-outlook.com/faq/duplicates.htm -- Brian Tillman [MVP-Outlook] ...

Problem with LeadTools CreateWindow inCFormView -Help !!!
Hi , I have been using LeadTools in Visual Studio 2005. I have a tabctrl and dialogs in each tab and developed using CFormView. So a tabCtrl is a child of CFromView and tab1 is a child of TabCtrl. I want to insert a LEAD control in one of the tabs .i.e, Dialog.I am unable to insert a leadcontrol but inserting a control in the view was easy.The problem is I am not able to get the HWND associated to a particular dialog which is super child of View. Can somebody help me in creating a lead control in the dialog configdlg .h LAnnotationWindow m_LAnnoWnd; FormView.cpp CMyTabCtrl m_myCtrlTab; ...

HelpProvider and HTML Help interaction
I have an application with a .chm help-file. But I have some questions about the behaviour of the help-window. I use a modal application window and I can start the help. The help windows appears but it is allways in foreground of my application window. I can set the input focus on my window, the help window becomes inactive but I cannot move my window over the help window. So I have to close the help window or minimize it or move it aside of my application window when I want to go on in my application. The other problem is when I minimize the help window and then open a dialog...

CString help
I'm looking at a website on CString Management: http://www.codeproject.com:80/string/cstringmgmt.asp In the section entitled, "CString to char * II: Using GetBuffer," the author stresses calling ReleaseBuffer after calling GetBuffer. Is this always necessary? I often use CString::GetBuffer when using CStrings in MessageBox dialogs like so: MessageBox(m_hWnd, cString.GetBuffer(0), lpTitle, MB_OK); Should I be adding a ReleaseBuffer after a MessageBox call? Should I be passing my string data to the MessageBox in another way? Regards, Joe > Is this always necessary?...

SUM and Frequency for Multiple SHeets
Hi....in sheet 1, I have a column that has unique numbers and using the following formula to lookup the field in sheet 46500! Column H and then count the unique frequencies in sheet 46500! column A. =SUM(1*(FREQUENCY(IF(('46500'!$H$2:$H$43207<>"")*('46500'!$H$2:$H$43207=$A4),'46500'!$A$2:$A$43207),'46500'!$A$2:$A$43207)>0)) How do I change that formula so that it also reads additional sheets (46501, 47400, 43100, 43103, 47300) and only counts the unique combination like the formula above does for one sheet? Please Help Yo...