.Re: Using Xsl to group by unique values

"Anas M. Nebuchadnezzar XXXVII" <Duck@Kronkltd.net> wrote in message news:DLWdneiY8IsBdKPdRVn-uQ@comcast.com...
> I'm not sure if this is the right forum to ask this, seeing this problem 
> is pretty much straight XSL, but here goes.
> I'm writting a simple employee database, and I want to be able to:
> A) get a node-set returning only unique values based off of a query. 
> (the names of all the managers)
> b) loop through each of the nodes, sorted by the list of the managers.
> My Xml looks something like this:
> <root>
>    <employee id="001">
>      <manager id="01"/>
>    </employee>
>    <employee id="002">
>      <manager id="01"/>
>    </employee>
>    <employee id="003"/>
>      <manager id="02"/>
>    </employee>
>    <employee id="004">
>      <manager id="03"/>
>    </employee>
>    <employee id="005">
>      <manager id="03"/>
>    </employee>
> And ideally I should be able to produce output like this:
> 01
> ------
> 001
> 002
> 02
> ------
> 003
> 03
> ------
> 004
> 005
> I figure this should simply be a matter of doing an apply-templates of 
> something along the line of {node-set of unique values of manager/@id} 
> and then I'd like to be able to select each value of 
> 'employee[manager/@id = {the current value of @id}]'. Unfortunatly I 
> can't figure out how to do this. Can anyone help me on this. I'm totally 
> stuck.

As simple as this:

<xsl:stylesheet version="1.0" 
 <xsl:output method="text"/>
 <xsl:key name="kMngById" match="manager" use="@id"/>
 <xsl:key name="kEmpByMng" match="employee" 
          use="manager/@id" />
  <xsl:template match="/">
    <xsl:for-each select=
       select="concat('&#xA;&#xA;', @id,
        <xsl:for-each select="key('kEmpByMng', @id)">
          <xsl:value-of select="concat('&#xA;', @id)"/>

When this transformation is applied on your source.xml (corrected it
to make it well-formed):

   <employee id="001">
     <manager id="01"/>
   <employee id="002">
     <manager id="01"/>
   <employee id="003">
     <manager id="02"/>
   <employee id="004">
     <manager id="03"/>
   <employee id="005">
     <manager id="03"/>

the wanted result is produced:





Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
dimitren (11)
2/27/2004 9:43:10 AM
dotnet.xml 7266 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 20


Similar Artilces:

Re: Junk mail doesnt filter when rules are enabled
Yes, I am dealing with this problem. I get mail from three pop accounts. I filter ALL my email based on what mail account it comes from and put it into a corresponding folder. Outlook catches ZERO percent of my junk mail because of this.... How can we get outlook junkfilter to work right?? Thanks. A very frustrated Lawrence "Sholom Deen" <sdeen@diamonds.net> wrote in message news:2ad7b851.0311061241.1a580be9@posting.google.com... > I'm having the same problem. Apparently, the junk filters are applied > before any rules, and since in 2003 the filters are not sim...

Suppressing categories with 0 values
Hi all I'm trying to build a dynamic chart for sales data. The output file contains two columns, A and B. Column A contains categories, i.e. Apples, Oranges, Pears, etc.,. and B contains sales data, i.e. 5, 0, 10, etc.,. respectively. The ouput data comes out monthly. Some months will contain sales from all categories, some ten, some fifty. I want the chart to only graph categories with non-zero values, i.e. if there are 100 categories and only 30 with sales numbers there is no point in showing the other 70 categories with zero values. I can format column B with zero values to show ...

Am I using the pop3 connector properly?
I currently host mail for udc.net on a machine running mailsite. I want to convert everyone over to exchange, but cannot do everyone at once. I believe that I need to use the pop3 connector. All MX records point to the current box running Mailsite. In exchange, I have created a pop3 connector for my own mailbox, and added the SMTP domain and email address for udc.net (so when I send mail, it will show me@udc.net as the from, and return address) I connector definately downloads mail from the pop3 mailbox. But it gets lost. The messages do not appear in my exchange mailbox. If I remove t...

using a UDF in place of a cond. format, b/c I need 4, not three
I know this is an age old topic here, and I'm really hoping that I don't just get referred to another web page [that type of help of course has its place and merits]. And if I had the time, I would have more fun going through docs and notes to find out how to do it, but time is not something I can barter. What I'm looking at is: I'm thinking along the lines of an example where I normally set the borders of my columns [except if it's the first row] in a cond. format via something like this: =AND((NOT(ISBLANK($A1))),(ROW()>1)) But, if I need that space for a Con...

Using Rules to Respond to Messages
I'm setting up resource scheduling and like some others have noticed, if a user submits a calendar item to a resource but puts the resource in the required or optional field the calendar has to accept or decline the meeting. Well, your resource is setup to automatically accept resource scheduling and no one is going to read the requests submitted as email. I was thinking I could setup a rule that automatically resonds to the user to tell them that they have selected a resource as a person. Please resubmit this request and put the resource in the resource field. PROBLEM: I can'...

PDFs do not display in OWA using FE/BE scenario, IE 6, Adobe Reader 7.0.7
Greetings, My organization is currently running Microsoft Exchange Server 2003 SP2 in a FE/BE scenario with the FE serving OWA. We are experiencing problems with our OWA users not being able to open PDF attachments within OWA when they are using IE 6 (fully patched) and Adobe Reader 7.0.7. After some testing, I have discovered the following: When using: Abobe Reader 7.0.7 and IE 6 (fully patched) - PDFs will not display in OWA (no errors given) Adobe Reader 7.0.7 and IE 7 Beta 2 - PDFs will display properly Adobe Reader 7.0.7 and Firefox (fully patched) - PDFs will display properly ...

RE: MSCRMDeletionService -- change frequency...
i am trying to modify the frequency for the MSCRMDeletionService...there is a registry value in the HKLM\Software\Microsoft\MSCRM\ key named DSRunInterval. one of our servers has this value as a REG_SZ (string) value while another server has it as a DWORD (number) value ; does anyone have an idea what format this value should be? and also is it based on seconds? thanks! sunish ...

Find a value in list 2 that is not in list 1
I have text values in column A and also in column B, most of which match. I would like to take the values in column B that are not in column A and put those values only in column C. Any help would be greatly appreciated. Maxxwell, Put this formula in column C, and copy down. =IF(ISERROR(MATCH(B2,$A$2:$A$20,0)),B2,"") To get them contiguous, use Autofilter, filter on nonblanks in column C, and copy/paste to somewhere. -- Earl Kiosterud mvpearl omitthisword at verizon period net ------------------------------------------- "maxxwell2" <maxxwell2@discussions.microsof...

Distribution Group Not Receiving Emails From Outside Organization
It's the strangest thing. I cannot figure out how this one particular group is not receiving emails from the outside, when it is configured exactly like all our other groups. Yes, its set to receive emails from everyone. Any thoughts? What happens? -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" <jaaboo@gmail.com> wrote in message news:1142898094.977528.109350@v46g2000cwv.googlegroups.com... > It's the strangest thing. I cannot figure out how this one particular > group is not receiving emails from the outside, when it is ...

Using Automation to Send HTML...
The following code used to work fine in Outlook 2000, now with Outlook 2002 it doesn't. Now it leaves a BLANK body. Can anyone tell me why this no longer works? Also, we try the same thing with an RTF type file as the body (.body property), and it just puts junk in the body and does not interpret it as a RTF file. Thanks. Bob ***************************************************** oOutlook = CREATEOBJECT("outlook.application") oMail = oOutLook.CreateItem(0) WITH m.oMail m.oRecipient = .Recipients.Add("test@test.com") m.oRecipient.type = 1 .Subject = &quo...

Moving mailboxes using Active Directory Users and Computers
This is a multi-part message in MIME format. ------=_NextPart_000_0022_01C61DC8.6FAD4950 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Question: When moving mailboxes using AD Users and Computers from = Exchange server A to Exchange Server B, what will be the effect on users = that currently have their mailbox open in Microsoft Outlook? Some of the = users have Outlook 2003 and some of them have Outlook 2002. Is it best = to do the move when noone is on? but the thing is in this organization, = we have so laptop users that may not be on...

I want a formula to ignore text values in cell references
If text is input into some cells referenced by a formula I want the formula to ignore whatever text it finds and just calculate the result of the numbers in cells. How do i do this? Presently the formula displays #VALUE! where there is text in one or more of the cells referenced. Use ISNUMBER(): In place of A1 use =IF(ISNUMBER(A1),A1,"") -- Gary''s Student "Russellrupert" wrote: > If text is input into some cells referenced by a formula I want the formula > to ignore whatever text it finds and just calculate the result of the numbers > in cells...

Copying text value based on long (comlex) calculation
I am not sure how to even search for what I want to do, so please forgive me if my first post has been discussed and resolved ad naseum in the past... Here is my situation: - I have a workbook that contains multiple sheets. - Each sheet contains auto parts from different suppliers, sorted by part number. - Some suppliers have parts that overlap with each other and the various sheets are updated as pricing and availabilty of parts change. - I am using a combination of the VLOOKUP and MIN functions to determine which supplier has lowest cost based on a comparison of part numbers and price ac...

Link to other slides from table using c#
Hi, I'm looking to create links from a certain slide to another, and I need those links to be from within a table. I need it to be something like this: var pptApp = new PowerPoint.Application(); var presentation = pptApp.Presentations.Add(Office.MsoTriState.msoFalse); var slides = presentation.Slides; slides.InsertFromFile(@"C:\Users\Tng1\Documents\PresentationTemplate.potx" , 0, 1); var titleSlide = slides[1]; titleSlide.Name="TitleSlide" ; var tableSlide = slides[2]; tableSlide.Name = "TableSlide" ; va...

Data validation for 2 valid values
I want a cell to allow only 2 valid values but not have a drop-down list appear. How do I do that with Data->Validation? Data>validation>allow>list, put the 2 values separated by a comma in the source box, uncheck in cell dropdown -- Regards, Peo Sjoblom "Hall" <hall@garp.org> wrote in message news:ujuB%23w52DHA.2000@TK2MSFTNGP11.phx.gbl... > I want a cell to allow only 2 valid values but not have a drop-down list > appear. > > How do I do that with Data->Validation? > > Using a list, as Peo suggested, will force users to match the ...

how do I get the x-axis to plot values rather than categories in .
how do I get the x-axis to plot values rather than categories in Excel By using an XY rather than a LINE chart -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "Boggins" <Boggins@discussions.microsoft.com> wrote in message news:2D963E4D-93C3-4E8A-83F1-A51943ED4CAA@microsoft.com... > how do I get the x-axis to plot values rather than categories in Excel ...

What's the best way to diagram a supply chain using Visio?
What's the best way to diagram a supply chain using Visio? ...

Nested query-based distribution groups?
We are currently trying to implement some query-based distribution groups. Is it possible to create one QBDG that has a couple of rules (for example all people with a certain job title) and then create another dynamic group that will start with all the users in the previous group (all people with a certain title) and further narrow it down with more rules? Basically does exchange 2003 allow for nested query-based groups? If so, how do you go about doing it? Thanks. Yes they can be nested. You would nest them just like you would nest any other group. http://support.microsoft.com/?id=82289...

Wanting to grab group of files and PkZip them.
I have an excel file that has two columns, Code and Filename. i.e. CODE Filename Abc 123456.txt Abc 123457.txt Def 123458.txt Def 123459.txt Etc… I would like to be able to select all files with a specific Code and have them zipped into a file that is named the same as the Code. i.e. Abc.zip would contain 123456.txt & 123457.txt AND Def.zip would contain 123458.txt & 123459.txt The file names are actually quite random but they are associated with specific codes according to this Excel file. I am creating an Access form that will allow users to browse to the Excel...

Sendinf personalised mails to a group using Outlook
Hi All, I would like to know how to send personalised mails to a group (keeping the groups in bcc) using outlook 2003/2007. Please share your thoughts. regards, Jaseel You have stated contradictory points. BCC does not "personalise" it just hides the recipient list. If you want to personalise, ie use data fields like first_name and last_name, you need to do a mailmerge to email. There are many posts here on how to do that. Regards Judy Gleeson MVP Outlook in Canberra, Australia "Jassy" <Jassy@discussions.microsoft.com> wrote in mes...

Sort Using Different Columns
I am trying to compile a list of sales by customer and total purchases by that customer in a series of months. I have column a as a master list of customer names. Column B is going to be the charges for that customer in lets say may. Column c is going to be the charges for that customer in June. The problem I am having is that not all customers have charged from us in the same months so when I bring my data into this worksheet it contains the customer name in one column and the charges in another. Doing this does not allow the customer names for one month to line up with the next m...

Entering vacation into a recurring batch using HR attendance
Hello, I have a client who maintains recurring batches and keeps track of vacation and sick payouts that way. We recently moved vacation and sick from payroll to HR. Now there is a restriction that does not allow entering these linked vacation/sick pay codes in a recurring batch. Is there around this or is it basic functionality of attendance? -- Greg. It's the way it is. You'd probably be better off with PTO Manager unless you need more than vacation and sick time. If you do, you'd want to look at Enterprise Leave Manager from Integrity. -- Charles Allen, MVP &quo...

Access exchange using IMAP
Hi There. I cannot access my email message using IMAP to exchange 2003. The statement as below: Connection refused Configuration: Account: Staffmail Server: User name: Staff\Taufik Protocol: IMAP Port: 143 Secure(SSL): 0 Code: 800cccd9 any ide how so solve it? thanks Have you started the IMAP service and made sure that IMAP access is enabled for your user account? Exchange 2003 disables IMAP and POP3 services by default. -- Ben Winzenz Exchange MVP MessageOne "Muhamad Taufik Khasim" <Taufik@uniten.edu.my> wrote in message news...

Using VBA
Hello, I have a summary timetable sheet, and each customer has a differen colour. If someone is due to visit them on day x, then the cell i shaded in that particular customer. I then have an individual sheet for each customer and I want to be abl to copy the formatting from the summary to the individual custome sheet without having to cut and paste for each individual customer. This is what I have so far Dim Cell As Object Dim CurrentCell As Object Range("B10:Y200").Select For Each Cell In Selection If Cell.Interior.ColorIndex = 52 Then Cell = CurrentCell Sheets("Cus...

Using "OR" in an IF statement
I am trying to use the command OR in an If statement and I am having no luck. In Lotus 123 I could string commands by using #OR# to produce a common result. For example: =IF(J3="INVEST" #OR# IF(K3 = "INVEST",1,"NO")) I can't seem to make this work in Excel. Can anyone provide me with a correction? Doug, Like this =IF(OR(J3="Invest",K3="Invest"),"The true condition","the false condition") If the true or false condition is numeric then drop the quotes -- Mike When competing hypotheses are other...