Help - use XSLT to group by multiple values?

Discussion in 'XML' started by n.phelge, Jul 23, 2007.

  1. n.phelge

    n.phelge Guest

    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
     
    n.phelge, Jul 23, 2007
    #1
    1. Advertising

  2. n.phelge

    Pavel Lepin Guest

    n.phelge <> wrote in
    <>:
    > I need to group the items together that have the same
    > values for StartDate and EndDate such that the output
    > looks like the following:


    [...]

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


    You know of the Muenchian grouping, but you 'haven't been
    successful', you didn't post any code, and you
    want 'assistance'? Do you want someone to write the code
    for you? This an entry-level grouping problem, do your own
    homework.

    --
    ....the pleasure of obedience is pretty thin compared with
    the pleasure of hearing a rotten tomato hit someone in the
    rear end. -- Garrison Keillor
     
    Pavel Lepin, Jul 23, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Hillsley
    Replies:
    3
    Views:
    1,731
    Dimitre Novatchev
    Sep 25, 2003
  2. Replies:
    2
    Views:
    733
    Henry S. Thompson
    Oct 19, 2005
  3. Replies:
    6
    Views:
    2,885
  4. Akaketwa
    Replies:
    1
    Views:
    5,015
    impaler
    Sep 22, 2006
  5. Replies:
    12
    Views:
    424
    Satish Kumar
    Apr 14, 2014
Loading...

Share This Page