473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can XQuery handle hierarchical data?

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>

Jul 20 '05 #1
5 1655
Neo
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)

Jul 20 '05 #2
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.

Jul 20 '05 #3
mi*****************@yahoo.com 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

Jul 20 '05 #5
Jan Hidders wrote:
mi*****************@yahoo.com 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...afp-slides.pdf
"A part hierarchy, with incremental costs"

Jul 20 '05 #6

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

Similar topics

0
2151
by: Tony Lavinio | last post by:
Dear Stylus Studio Friends, The new year is scarcely one month old, but we already have lots to report! For starters, there's Stylus Studio 6 Release 2. The latest release of Stylus Studio...
0
1464
by: Tony Lavinio | last post by:
Dear comp.text.xml community, Microsoft recently announced that they are dropping XQuery from their next release of the .NET Framework, 2.0 (Whidbey). Since Microsoft ships .NET Framework only...
0
2287
by: Stylus Studio | last post by:
DataDirect XQuery(TM) is the First Embeddable Component for XQuery That is Modeled after the XQuery API for Java(TM) (XQJ) BEDFORD, Mass.--Sept. 20, 2005--DataDirect Technologies...
0
1261
by: HNguyen | last post by:
Hi, I have a problem of binding data from XQuery to a dataset. Here is the program I've extracted from 4guysfromrolla.com. This program read data from an XML file (Employees.xml) and performed...
2
2258
by: Daniel | last post by:
update/insert with microsoft.xml.xquery(.net2.0beta) can anyone provide an example of how to update/insert with microsoft.xml.xquery?
1
1739
by: Daniel Poetzinger | last post by:
Hello List Sorry if this question is too simple or unreleated, but I didn't found an answer yet: How is it possible to handle an element: <test>1 2 3 4</test> as sequence of atomic types...
2
1737
by: BK | last post by:
I am working on system that will have a cataloging component which would essentially be a Folder/File structure. So far I have coded the Iteration over a selected folder and am displaying the...
1
1421
by: Kiran | last post by:
See the docs: http://news.zdnet.com/2100-9593_22-6057835.html Download: http://www.ibm.com/software/data/db2/udb/viper/index_download.html Docs:...
0
1197
by: sudheerdb2 | last post by:
Hi, I am trying xml data processing using Xquery version 9.1 My xml file --------- <?xml version="1.0" ?> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
0
7260
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
7160
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
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5685
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
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.