Can XQuery handle hierarchical data?

Discussion in 'XML' started by mikharakiri_nospaum@yahoo.com, Jan 14, 2005.

  1. Guest

    Is hierarchical aggregated total expressible in XQuery? Given

    <emp name = ALLEN sal = 2000>
    <emp name = SMITH sal = 1500>
    </emp>
    <emp name = MILLER sal = 1800>
    <emp name = ADAMS sal = 1000>
    </emp>
    </emp>
    </emp>

    the result is supposed to be

    <emp name = ALLEN budget = 4300>
    <emp name = SMITH budget = 1500>
    </emp>
    <emp name = MILLER budget = 2800>
    <emp name = ADAMS budget = 1000>
    </emp>
    </emp>
    </emp>
     
    , Jan 14, 2005
    #1
    1. Advertising

  2. Neo Guest

    Script below models the hierarchy with an experimental db (not XQuery)
    and walks the tree recursively.

    // Create persons
    (CREATE *person.item ~in = dir)
    (CREATE *allen.cls = person)
    (CREATE *smith.cls = person)
    (CREATE *miller.cls = person)
    (CREATE *adam.cls = person)

    // Create salaries
    (CREATE *salary.item ~in = dir)
    (CREATE allen.salary=+2000)
    (CREATE smith.salary=+1500)
    (CREATE miller.salary=+1800)
    (CREATE adam.salary=+1000)

    // Create verbs for heirarchy
    (CREATE *boss.cls = verb)
    (CREATE boss.vbType = kr)
    (CREATE *employee.cls = verb)
    (CREATE employee.vbType = cr)
    (CREATE boss.opposite = employee)

    // Create hierarchy
    (CREATE allen.employee = smith)
    (CREATE allen.employee = miller)
    (CREATE miller.employee = adam)

    // Selects allen's empolyees recursively
    // Selects smith, miller, adam
    (SELECTR allen.employee)
     
    Neo, Jan 14, 2005
    #2
    1. Advertising

  3. Guest

    Neo wrote:
    > Script below models the hierarchy with an experimental db (not

    XQuery)
    > and walks the tree recursively.

    ....

    Impressive! When googled "Bill of materials XQuery", however, the first
    entry is 3 pages of spaghetty code in XSLT:
    http://forums.tamino.com/3/OpenTopic?a=tpc&f=7922934291&m=656106161"
    Try to beat that!

    Now, every other google reference on that page claims that Bill of
    materials extremely easy to do in XML. Which bill of materials? Finding
    all the descendants? Perhaps. The question is if query ability scales
    up so something little more complicated than that. Finding aggrergated
    cost of all the subparts, for example.
     
    , Jan 14, 2005
    #3
  4. Guest

  5. Jan Hidders Guest

    wrote:
    > Is hierarchical aggregated total expressible in XQuery? Given
    >
    > <emp name = ALLEN sal = 2000>
    > <emp name = SMITH sal = 1500>
    > </emp>
    > <emp name = MILLER sal = 1800>
    > <emp name = ADAMS sal = 1000>
    > </emp>
    > </emp>
    > </emp>
    >
    > the result is supposed to be
    >
    > <emp name = ALLEN budget = 4300>
    > <emp name = SMITH budget = 1500>
    > </emp>
    > <emp name = MILLER budget = 2800>
    > <emp name = ADAMS budget = 1000>
    > </emp>
    > </emp>
    > </emp>


    Hi Mikito,

    Did you already find the answer?

    -- Jan Hidders
     
    Jan Hidders, Jan 30, 2005
    #5
  6. Guest

    Jan Hidders wrote:
    > wrote:
    > > Is hierarchical aggregated total expressible in XQuery? Given
    > >
    > > <emp name = ALLEN sal = 2000>
    > > <emp name = SMITH sal = 1500>
    > > </emp>
    > > <emp name = MILLER sal = 1800>
    > > <emp name = ADAMS sal = 1000>
    > > </emp>
    > > </emp>
    > > </emp>
    > >
    > > the result is supposed to be
    > >
    > > <emp name = ALLEN budget = 4300>
    > > <emp name = SMITH budget = 1500>
    > > </emp>
    > > <emp name = MILLER budget = 2800>
    > > <emp name = ADAMS budget = 1000>
    > > </emp>
    > > </emp>
    > > </emp>

    >
    > Hi Mikito,
    >
    > Did you already find the answer?


    http://homepages.inf.ed.ac.uk/wadler/papers/xquery-afp/xquery-afp-slides.pdf
    "A part hierarchy, with incremental costs"
     
    , Jan 30, 2005
    #6
    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. HNguyen
    Replies:
    0
    Views:
    1,184
    HNguyen
    Jun 3, 2004
  2. neverstill

    Binding hierarchical data

    neverstill, Dec 8, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    1,208
    Anders Borum
    Dec 9, 2003
  3. PontiMax

    Updating hierarchical data

    PontiMax, Dec 17, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    395
    PontiMax
    Dec 17, 2003
  4. Neil McGuigan

    managing hierarchical data - categories

    Neil McGuigan, Mar 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    398
    \(Laurent Jordi\)
    Mar 6, 2004
  5. HNguyen

    Binding data from XQuery to a dataset

    HNguyen, Jun 3, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    404
    HNguyen
    Jun 3, 2004
Loading...

Share This Page