473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Grouping over multiple nodes - possible?

Seeing how my previous post seem to have fallen between the
cracks, I thought I would have a second, more direct, go at it.

So my question is "Is it possible to group (Muenchian method)
over multiple nodes?" I will use an example to try to explain what
I need to do and what I have for data. The example might not be
very realistic but it's much easier than to try and explain using the
scenario I have =P

Suppose I had a list of locations for which shipped packages has
been sent. Each item (Segment node) details the following

* Which package does it describe (PackageId)
* Where was is shipped from (City1)
* Where did it arrive (City2)
* When was it shipped (DateTime1)
* When did it arrive (DateTime2)
* Which shipping direction (Direction)

<Segment>
<PackageId></PackageId>
<City1></City1>
<City2></City2>
<DateTime1></DateTime1>
<DateTime2></DateTime2>
<Direction></Direction>
</Segment>

Each package might pass 1-n (one to many) terminals on its way
to the final destination, so I can have multiple segments for the same
package and they are all identified by the PackageId node.

Now this information is logged for packages going out, as well as
for returns, this is stored in the Direction node where a value of 1
means shipped out and 2 means a return.

Now I will try to round it of to keep the lenght down. Basiclly what I
want to do it get out each unique (distinct) travel route of all packages
in a given direction.

This is why I need to be able to group (create my key) from ALL of the
Segments for a given package and match it with the travel routes of the
other packages (lets assume tha the DateTime1 and DateTime2 nodes
only contain on the hour times like 07:00, 12:00 etc).

Package 1 and 2 might have been shipped the same route (say 3 segments)
meaning they've both passed the same terminals at the same time. Then I
only want to get the 3 segments once. And then package 3 was also sent the
same route but at a different date then I want those 3 segments as well.

Damit this is hard to explain =(

Hope it makes atleast some scense. All feedback is welcome, even if you
don't have the full solution at - your feedback might help find the final
solution.

/Andreas
hand

Nov 12 '05 #1
2 1678
Andreas Håkansson wrote:
So my question is "Is it possible to group (Muenchian method)
over multiple nodes?" I will use an example to try to explain what
I need to do and what I have for data. The example might not be
very realistic but it's much easier than to try and explain using the
scenario I have =P
Well, I'm not sure I get it, but take a look at Jeni Tennison's page on
XSLT grouping - http://www.jenitennison.com/xslt/grouping/. In includes
explanation on multiple level grouping too.
Now I will try to round it of to keep the lenght down. Basiclly what I
want to do it get out each unique (distinct) travel route of all packages
in a given direction.


Well, some sample would be helpful here.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> skrev i
meddelandet news:uI**************@TK2MSFTNGP12.phx.gbl...
Andreas Håkansson wrote:
Now I will try to round it of to keep the lenght down. Basiclly what I
want to do it get out each unique (distinct) travel route of all packages
in a given direction.

Well, some sample would be helpful here.


Ok I will try to provide an example. The problem is that there are so many
variations which I could illustrate in an example, although the main concept
is the same for each situation.

Lets back up and have a look at the XML which looks like this.

<Package>
<Id>12345</Id>
<Price>100</Price>
<Catagory>AAA</Catagory>
<Routs>
<Route>
<City1>A</City1>
<City2>B</City2>
<DateTime1>10:00</DateTime1>
<DateTime2>11:15</DateTime2>
<Direction>1</Direction>
</Route>
<Route>
<City1>B</City1>
<City2>C</City2>
<DateTime1>12:00</DateTime1>
<DateTime2>14:00</DateTime2>
<Direction>1</Direction>
</Route>
<Route>
<City1>C</City1>
<City2>A</City2>
<DateTime1>07:00</DateTime1>
<DateTime2>10:00</DateTime2>
<Direction>2</Direction>
</Route>
</Routs>
</Package>
<Package>
<Id>12346</Id>
<Price>100</Price>
<Catagory>AAA</Catagory>
<Routs>
<Route>
<City1>A</City1>
<City2>B</City2>
<DateTime1>10:00</DateTime1>
<DateTime2>11:15</DateTime2>
<Direction>1</Direction>
</Route>
<Route>
<City1>B</City1>
<City2>C</City2>
<DateTime1>12:00</DateTime1>
<DateTime2>14:00</DateTime2>
<Direction>1</Direction>
</Route>
<Route>
<City1>C</City1>
<City2>A</City2>
<DateTime1>07:00</DateTime1>
<DateTime2>10:00</DateTime2>
<Direction>2</Direction>
</Route>
</Routs>
</Package>
<Package>
<Id>12346</Id>
<Price>100</Price>
<Catagory>AAA</Catagory>
<Routs>
<Route>
<City1>A</City1>
<City2>B</City2>
<DateTime1>16:00</DateTime1>
<DateTime2>17:15</DateTime2>
<Direction>1</Direction>
</Route>
<Route>
<City1>B</City1>
<City2>C</City2>
<DateTime1>08:00</DateTime1>
<DateTime2>10:00</DateTime2>
<Direction>2</Direction>
</Route>
<Route>
<City1>C</City1>
<City2>A</City2>
<DateTime1>11:00</DateTime1>
<DateTime2>12:30</DateTime2>
<Direction>2</Direction>
</Route>
</Routs>
</Package>
<Package>
<Id>12348</Id>
<Price>150</Price>
<Catagory>AAA</Catagory>
<Routs>
<Route>
<City1>A</City1>
<City2>B</City2>
<DateTime1>10:00</DateTime1>
<DateTime2>11:15</DateTime2>
<Direction>1</Direction>
</Route>
<Route>
<City1>B</City1>
<City2>C</City2>
<DateTime1>12:00</DateTime1>
<DateTime2>14:00</DateTime2>
<Direction>1</Direction>
</Route>
<Route>
<City1>C</City1>
<City2>A</City2>
<DateTime1>07:00</DateTime1>
<DateTime2>10:00</DateTime2>
<Direction>2</Direction>
</Route>
</Routs>
</Package>

We have a list of packages - each packade is identified by an Id and
also stores the Price and Catagory of the package. The route for which
the package was shipped to it's location and back again is stored together
with the package.

The first level of grouping is by PRICE and CAtAGORY. This means that
the three first packages are grouped since they share the same price and
catagory. So far I have no problem.

It is the next grouping/filtering/selection level which is the source of my
problems :) Once the first level of grouping has been applied, I want to
get all of the unique combinations of Route items for the packages which
was grouped in level 1.

So If we only look at the first 3 packages and only on the routes with
direction 1 (since it will be the same for Direction 2 - I want to include
them
as well but for simplicity I think I can omitt them in this example, just
keep
in mind that direction 2 should be included as well although only compared
with other direction 2 routes in the same group) we have
<City1>A</City1>
<City2>B</City2>
<DateTime1>10:00</DateTime1>
<DateTime2>11:15</DateTime2>

<City1>B</City1>
<City2>C</City2>
<DateTime1>12:00</DateTime1>
<DateTime2>14:00</DateTime2>

<City1>A</City1>
<City2>B</City2>
<DateTime1>10:00</DateTime1>
<DateTime2>11:15</DateTime2>

<City1>B</City1>
<City2>C</City2>
<DateTime1>12:00</DateTime1>
<DateTime2>14:00</DateTime2>

<City1>A</City1>
<City2>B</City2>
<DateTime1>16:00</DateTime1>
<DateTime2>17:15</DateTime2>

Which should be shortened to the distinct routes.

A B 10:00 11:15
B C 12:00 14:00

A B 16:00 17:15

Now Imagine we also have the same information for Direction 2. What I have a
need
for in my application is to hav ethe user select one of the DISTINCT routes
for direction 1
and one of the DISTINCT routes for direction 2. When he/she has done this I
need to match
them with the package/packages which contains this pair of routes. This
means I will need to
store the Package ID with the transformed routes.

So still only illustrating with the help of Direction 1 routes I need
something like this to be
stored with the distinct routes for the first level of grouping.

<Routes>
<Route>
<City1>A</City1>
<City2>B</City2>
<DateTime1>10:00</DateTime1>
<DateTime2>11:15</DateTime2>
<Packages>
<Package>12345</Package>
<Package>12346</Package>
</Packages>
</Route>
<Route>
<City1>B</City1>
<City2>C</City2>
<DateTime1>12:00</DateTime1>
<DateTime2>14:00</DateTime2>
<Packages>
<Package>12345</Package>
<Package>12346</Package>
</Packages>
</Route>
<Route>
<City1>A</City1>
<City2>B</City2>
<DateTime1>16:00</DateTime1>
<DateTime2>17:15</DateTime2>
<Packages>
<Package>12347</Package>
</Packages>
</Route>
</Routes>

So what I have done (in theory ;) is first group by PRICE and CATAGORY. Then
I
select the DISTINCT routes withing each of the groupes (in my examples I
have only
illustrated from within one group) and store information with each route
about which
packages used that route.

If I get this far then I have no problem doing the reverse lookup which is
when I go from
Direction 1 & 2 pair of routes -> one or many packages which contains the
route pair in
question.

Maybe it is easier to think of it like flight itineraries. You want to fly
from A to B and get
a bounch of Itineraries, each detailing which route if will fly (stops and
time for each stop).

You start of by grouping them by thier Price and Carrier. Then you precede
to get each of
the unique routes for the trip from A to B. You then decide I want to fly
from point A to B
at Time1 and Time2 .and then back from B to A at Time1 and Time2. Once you
have decided
this you look up which Itinerary contains the desired route pair and get
it's ID (this last part
is what I described with the Packages node in the last XML text.

Hope this made it a bit more clear what I want to do? I'm having a really
hard time explaining
this in a clear way! ;)

//Andreas
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike King | last post by:
I don't know how to group the following data in the way I want it. I want the output of the transformation to be "5678". Does anyone know what I am doing worry? <?xml version="1.0"?> <data>...
4
by: kristofera | last post by:
I am trying to do a distinct grouping of some nodes sorted by a numeric value but for some reason the distinct (preceding-sibling filter) is applied to the result as if not sorted. If I don't use...
3
by: Andreas Håkansson | last post by:
Is it possible to create an id over multiple nodes? I would like to use generate-id which includes all of the Route nodes which has a direction of 1. So I don't want to for-each each Route node...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
2
by: jon|k | last post by:
hi all-- i need to do a transformation that removes duplicates (among other things). to accomplish that, i'm trying to use for-each-group, but it doesn't work. i need to select for duplicates by...
0
by: mlg1906 | last post by:
I am developing an intranet site that uses 3 menus. Menus 1 and 2 are horizontal menus at the top of my page. The 3rd menu is a vertical menu on the left. All of the possible nodes have been loaded...
1
by: lennyw | last post by:
Hi I'm trying to use XSLT to do an xml to xml transformation where the output xml contains summary data on the information in the input xml. I've succesfully done a Muenchian grouping of the...
1
by: icfai | last post by:
hi friends.... I have got a problem regarding loading of multiple assemblies, actually its required for an editor which implements the intellisenseas in vb or dotnet. for that it is required to...
4
by: MRe | last post by:
Hi, Is it possible using XSLT to transform this.. <test> <b>0</b> <a>1</a> <a>2</a> <b>3</b> <b>4</b>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.