Assistance and explanation for a xquery on xml issues -


i new xquery , can't following simple query work:

list names of students , mentors.

where there student xml studentid , mentorid, instructorxml instructorid matchers mentorid, , person xml names , id matches studentid , instructorid.

    $saxon:>      <table border="1" >      <tr> <td>student</td> <td >mentor</td> </tr>     {     $s in doc("coms363/projects/datasets/student.xml"),     $i in doc("coms363/projects/datasets/instructor.xml"),     $p in doc("coms363/projects/datasets/person.xml")     $s/mentorid/text() = $i/instructorid/text()     , $s/studentid/text() = $p/id/text()     ,  $i/instructorid/text() = $p/id/text()     return <tr> <td>{$p/name/text()}</td> <td>{$p/name/text()}</td> </tr>     }     </table> ;  

i tried above code doesn't work. problem syntax issues or logic issues need figuring out , fixing problem. thank you.

you haven't shown xml source documents. however, query doesn't make sense

where $s/mentorid/text() = $i/instructorid/text()     , $s/studentid/text() = $p/id/text() 

$s/mentorid select if outermost element of $s mentorid element, while $s/studentid select if outermost element studentid element. can't both!

note also, use of /text() bad practice.

i expect see this, guessing element names:

for $s in doc("coms363/projects/datasets/student.xml")/students/student,     $i in doc("coms363/projects/datasets/instructor.xml")/instructors/instructor,     $p in doc("coms363/projects/datasets/person.xml")/persons/person     $s/mentorid = $i/instructorid     , $s/studentid = $p/id     ,  $i/instructorid = $p/id     return <tr> <td>{$p/id}</td> <td>{$p/name}</td> </tr> 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -