xpath query

Discussion in 'XML' started by Sebastian Paral, Nov 27, 2005.

  1. 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
     
    Sebastian Paral, Nov 27, 2005
    #1
    1. Advertising

  2. In article <438a40f6$0$6863$>,
    Sebastian Paral <> 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
     
    Richard Tobin, Nov 28, 2005
    #2
    1. Advertising

  3. > 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
     
    Sebastian Paral, Nov 28, 2005
    #3
  4. Sebastian Paral

    Stefan Ram Guest

    XML validator (was: xpath query)

    (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
     
    Stefan Ram, Dec 2, 2005
    #4
  5. Richard Tobin, Dec 2, 2005
    #5
    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. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,976
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,418
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    529
  4. goog
    Replies:
    0
    Views:
    512
  5. David Gordon

    xpath query query

    David Gordon, May 18, 2005, in forum: XML
    Replies:
    2
    Views:
    798
    David Gordon
    May 18, 2005
Loading...

Share This Page