untitled

(ff) #1

388 17 Answers to Selected Exercises


for $citation in document("pubmed.xml")//MedlineCitation
where exists
(for $heading in $citation//MeshHeading
where $heading/DescriptorName/@MajorTopicYN="Y"
and $heading/DescriptorName="Glutethimide"
and $heading/QualifierName="therapeutic use"
return $heading)
return $citation
ANSWER TO
EXERCISE8.5
To solve this exercise, extract all pairs of interviews for the same subject such
that the second interview is more than 2 years later, and the BMI attribute is
morethan4.5larger.

for $i in document("healthstudy.xml")//Interview,
$j in document("healthstudy.xml")//Interview
where $i/@SID = $j/@SID
and $j/@BMI - $i/@BMI > 4.5
and $j/@Date - $i/@Date < "P2Y"
return $i/@SID

This query can return the same subject identifier more than once when a
ANSWER TO subject satisfies the criteria multiple times.
EXERCISE8.6
The number of associations is specified by then_associationsattribute of
thego:termelement. The term number is specified by thego:accession
element. The GO namespace must be declared prior to using it in the query.

declare namespace
go="http://www.geneontology.org/dtds/go.dtd#";
document("go.xml")
//go:term[go:accession="GO:0003673"]/@n_associations

Unfortunately, the GO is a very large ontology. When the associations are
included, the GO is a 500 megabyte file. A query such as the one above
would have to read the entire file, which can take a long time. More efficient
techniques for querying such a large ontology were discussed in section 6.3.
ANSWER TO
EXERCISE11.1
Here is one possible solution:
Free download pdf