Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xpath query

Reply
Thread Tools

xpath query

 
 
Sebastian Paral
Guest
Posts: n/a
 
      11-27-2005
Hi, i got an xml database like this:

<conferencemanager>

<person pid="p1"><name>Sebastian</name></person>
<person pid="p2"><name>Christian</name></person>
<person pid="p3"><name>Maria</name></person>
<person pid="p4"><name>Georg</name></person>
<person pid="p5"><name>Sabine</name></person>

<conference kid="k1">
<name>Conference Nr. 1</name>
<date>10.10.2005</date>
<location>Graz</location>
</conference>

<conference kid="k2">
<name>Conference Nr. 2</name>
<date>10.10.2005</date>
<location>Vienna</location>
</conference>

<conference kid="k3">
<name>Konferenz Nr. 3</name>
<date>10.10.2005</date>
<location>Vienna</location>
</conference>

<lecture vid="v1"><title>DBMS</title></lecture>
<lecture vid="v2"><title>Distributed Systems</title></lecture>
<lecture vid="v3"><title>Computer Science</title></lecture>

<attendance pid="p1" kid="k1" vid="v1" />
<attendance pid="p2" kid="k2" vid="v2" />
<attendance pid="p3" kid="k2" vid="v1" />
<attendance pid="p4" kid="k2" vid="v1" />
<attendance pid="p5" kid="k2" vid="v1" />
<attendance pid="p5" kid="k3" vid="v3" />
<attendance pid="p3" kid="k2" vid="v1" />

</conferencemanager>

my assignment is as follows:
find all names (person) which have ever seen (attendance) conferences
(conference) in "vienna" about the "DBMS" lecture. this query should be
created with xpath.

in xquery it would be:

for $p in /conferencemanager/person,
$k in /conferencemanager/conference,
$v in /conferencemanager/lecture,
$t in /conferencemanager/attendance
where $t/@pid = $p/@pid and $t/@kid = $k/@kid and $t/@vid = $v/@vid
and $v/title = "DBMS" and $k/location = "Vienna"
return string($p/name)

is there a possibility to create an equivalent query only with xpath?
thanks for any help!

regards
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      11-28-2005
In article <438a40f6$0$6863$(E-Mail Removed) ekom.at>,
Sebastian Paral <(E-Mail Removed)> wrote:

>my assignment is as follows:
>find all names (person) which have ever seen (attendance) conferences
>(conference) in "vienna" about the "DBMS" lecture. this query should be
>created with xpath.
>
>in xquery it would be:
>
>for $p in /conferencemanager/person,
> $k in /conferencemanager/conference,
> $v in /conferencemanager/lecture,
> $t in /conferencemanager/attendance
>where $t/@pid = $p/@pid and $t/@kid = $k/@kid and $t/@vid = $v/@vid
>and $v/title = "DBMS" and $k/location = "Vienna"
>return string($p/name)
>
>is there a possibility to create an equivalent query only with xpath?
>thanks for any help!


Yes. You want the name of a person who was had an attendance:

//person[@pid = //attendance[...]/@pid]/name

Where the attendance has a conference with location Vienna:

@kid = //conference[location="Vienna"]/@kid

and a lecture with subject DBMS:

@vid = //lecture[title = "DBMS"]/@vid]

So put the second and third expressions in the predicate of the first.

-- Richard
 
Reply With Quote
 
 
 
 
Sebastian Paral
Guest
Posts: n/a
 
      11-28-2005
> Yes. You want the name of a person who was had an attendance:
>
> //person[@pid = //attendance[...]/@pid]/name
>
> Where the attendance has a conference with location Vienna:
>
> @kid = //conference[location="Vienna"]/@kid
>
> and a lecture with subject DBMS:
>
> @vid = //lecture[title = "DBMS"]/@vid]
>
> So put the second and third expressions in the predicate of the first.
>
> -- Richard


Hey, nice going... thank you very much!
regards
 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      12-02-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) (Richard Tobin) writes:
>So put the second and third expressions in the predicate of the first.


Is it possible that your validator at

http://www.hcrc.ed.ac.uk/~richard/xml-check.cgi

has disappeared or has been moved to another URI?

Recently I was not able to use it, I received:

HTTP/1.1 404 Not Found

 
Reply With Quote
 
Richard Tobin
Guest
Posts: n/a
 
      12-02-2005
In article <(E-Mail Removed)-berlin.de>,
Stefan Ram <(E-Mail Removed)-berlin.de> wrote:

> Is it possible that your validator at
>
>http://www.hcrc.ed.ac.uk/~richard/xml-check.cgi
>
> has disappeared or has been moved to another URI?


Um, yes, it seems to have vanished. It may be a consequence of some
changes to the web server here. I'll get it restored, but in the
meantime you can still access it at

http://www.cogsci.ed.ac.uk/~richard/xml-check.html

-- Richard
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
xpath query query David Gordon XML 2 05-18-2005 03:33 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments