Creating new subtotal nodes grouped by 2 values

Discussion in 'XML' started by J. T., Aug 11, 2004.

  1. J. T.

    J. T. Guest

    I'm fairly new to XSL, but have made some good progress in picking it
    up for the project I'm currently working on. I've been trying to
    figure out how to design a stylesheet that would transform the XML I'm
    recieving so that the tax information I'm recieving per item could be
    grouped and added per state and have the new subtotal node located
    inside the last node of a particular STORE value.

    I'm trying to use the Muenchian Method, but I can't seem to wrap my
    brain around it. The XML is already sorted by STORE, so I'm just
    trying to figure out how to use Muenchian properly to get the desired
    XML. I could really use some help in trying to figure out how to
    group and subtotal the tax nodes and get the output I desire. Thanks
    in advance.

    Input:

    <INV>
    <PAGE num="1">
    <STORE>1</STORE>
    <ITEM>X</ITEM>
    <TAX num="1">
    <STATE>GA</STATE>
    <TOTAL>10</TOTAL>
    </TAX>
    </PAGE>

    <PAGE num="2">
    <STORE>1</STORE>
    <ITEM>Y</ITEM>
    <TAX num="1">
    <STATE>GA</STATE>
    <TOTAL>5</TOTAL>
    <TAX>
    </TAX num="2">
    <STATE>FL</STATE>
    <TOTAL>5</TOTAL>
    </TAX>
    </PAGE>

    <PAGE num="3">
    <STORE>1</STORE>
    <ITEM>Misc.</ITEM>
    <TAX num="1">
    <STATE>FL</STATE>
    <TOTAL>5</TOTAL>
    <TAX>
    </TAX num="2">
    <STATE>SC</STATE>
    <TOTAL>5</TOTAL>
    </TAX>
    </PAGE>

    <PAGE num="4">
    <STORE>2</STORE>
    <ITEM>Z</ITEM>
    <TAX num="1">
    <STATE>GA</STATE>
    <TOTAL>0</TOTAL>
    </TAX>
    </PAGE>
    </INV>

    Desired Output:

    <INV>
    <PAGE num="1">
    <STORE>1</STORE>
    <ITEM>X</ITEM>
    </PAGE>
    <PAGE num="2">
    <STORE>1</STORE>
    <ITEM>Y</ITEM>
    </PAGE>
    <PAGE num="3">
    <STORE>1</STORE>
    <ITEM>Misc.</ITEM>
    <TAX_SUBTOTAL>
    <SUB_TAX num="1">
    <SUB_STATE>GA</STATE>
    <SUB_TOTAL>15</STATE>
    </SUB_TAX>
    <SUB_TAX num="2">
    <SUB_STATE>SC</STATE>
    <SUB_TOTAL>5</STATE>
    </SUB_TAX>
    <SUB_TAX num="3">
    <SUB_STATE>FL</STATE>
    <SUB_TOTAL>10</STATE>
    </SUB_TAX>
    <TAX_SUBTOTAL>
    </PAGE>
    <PAGE num="4">
    <STORE>2</STORE>
    <ITEM>Z</ITEM>
    <TAX_SUBTOTAL>
    <SUB_TAX num="2">
    <SUB_STATE>GA</STATE>
    <SUB_TOTAL>0</STATE>
    </SUB_TAX>
    <TAX_SUBTOTAL>
    </PAGE>
    </INV>
     
    J. T., Aug 11, 2004
    #1
    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. GaryB
    Replies:
    7
    Views:
    4,730
    Steven Cheng[MSFT]
    Nov 9, 2004
  2. Sparky Arbuckle

    FOR EACH - NEXT SubTotal Calculation

    Sparky Arbuckle, Feb 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    357
    Sparky Arbuckle
    Feb 25, 2005
  3. Sparky Arbuckle

    Calculating a Subtotal for Shopping Cart

    Sparky Arbuckle, Mar 6, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    1,647
    Sparky Arbuckle
    Mar 6, 2005
  4. Replies:
    1
    Views:
    578
    Soren Kuula
    Aug 24, 2006
  5. Ken
    Replies:
    1
    Views:
    2,005
    Teemu Keiski
    Sep 2, 2007
Loading...

Share This Page