Knowee
Questions
Features
Study Tools

<?xml version = "1.0”?> <walks> <trek name = "Kepler"> <location>Fiordland</location> <difficulty>moderate</difficulty> <length>60km</length> <rating>88</rating> </trek> <trek name = "Routeburn"> <location>Fiordland</location> <difficulty>moderate</difficulty> <length>32km</length> <rating>98</rating> </trek> <trek name = "Togariro"> <location>Togariro</location> <difficulty>hard</difficulty> <length>19.4km</length> <rating>96</rating> </trek> <walks>所选文本: Write down the following English language queries in XQuery, and show the result of evaluating the XQuery query on the given XML document.For the longest treks among those with difficulty moderate, return an element node labelled trek with i) attribute child name that contains the name of the trek and ii) an element child labelled rating that has the text of the rating of the trek as content.

Question

<?xml version = "1.0”?> <walks> <trek name = "Kepler"> <location>Fiordland</location> <difficulty>moderate</difficulty> <length>60km</length> <rating>88</rating> </trek> <trek name = "Routeburn"> <location>Fiordland</location> <difficulty>moderate</difficulty> <length>32km</length> <rating>98</rating> </trek> <trek name = "Togariro"> <location>Togariro</location> <difficulty>hard</difficulty> <length>19.4km</length> <rating>96</rating> </trek> <walks>所选文本: Write down the following English language queries in XQuery, and show the result of evaluating the XQuery query on the given XML document.For the longest treks among those with difficulty moderate, return an element node labelled trek with i) attribute child name that contains the name of the trek and ii) an element child labelled rating that has the text of the rating of the trek as content.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The XQuery for the given XML document would be:

let $doc := document("your_xml_file.xml")
let $moderate := $doc/walks/trek[difficulty='moderate']
let $longest := max($moderate/length)
for $trek in $moderate
where $trek/length = $longest
return 
<trek name="{$trek/@name}">
    <rating>{$trek/rating/text()}</rating>
</trek>

This XQuery first selects all the treks with moderate difficulty. Then it finds the maximum length among these treks. Finally, it returns the trek name and rating for the trek(s) with the maximum length.

Please replace "your_xml_file.xml" with the actual path to your XML file. The result of this query will depend on the content of your XML file.

This problem has been solved

Similar Questions

let $moderate_treks := //walks/trek[difficulty='moderate'] let $longest_length := max($moderate_treks/length) for $trek in $moderate_treks where $trek/length = $longest_length return <trek name="{$trek/@name}"> <rating>{$trek/rating/text()}</rating> </trek>err:FORG0001: Cannot cast <length>60km</length> to double

Consider the following XML document. <?xml v e r si o n = ‘ ‘1.0”? > <walks> <t r e k name= ‘ ‘ Keple r”> <l o c a ti o n >Fi o rdl and </l o c a ti o n > <d i f f i c u l t y >moderate</ d i f f i c u l t y > <len g th >60km</len g th> <r a ti n g >88</ r a ti n g > </t re k> <t r e k name= ‘ ‘ Routeburn”> <l o c a ti o n >Fi o rdl and </l o c a ti o n > <d i f f i c u l t y >moderate</ d i f f i c u l t y > <len g th >32km</len g th> <r a ti n g >98</ r a ti n g > </t re k> <t r e k name= ‘ ‘ T on g a ri r o C r o s si n g”> <l o c a ti o n >Tongariro </l o c a ti o n > <d i f f i c u l t y >hard</ d i f f i c u l t y > <len g th >19.4km</len g th> <r a ti n g >96</ r a ti n g > </t re k> <walks>For every distinct location l for which no trek with rating less than 85 exists, return an element node with label location that has the following content: i) a child element labelled location name with the name of the location as text content, and ii) for each trek in that location, an element child labelled trek with the name of the trek as text content.

The VoyageDraw or find a map that shows the route Magellan and his crew took.Mention some of the places they stopped along the way.

Write down the following English language queries in XQuery, and show the result of evaluating the XQuery query on the given XML document. (a) For every distinct location l for which no trek with rating less than 85 exists, return an element node with label location that has the following content: i) a child element labelled location name with the name of the location as text content, and ii) for each trek in that location, an element child labelled trek with the name of the trek as text content.

Write down the following English language queries in XQuery, and show the result of evaluating the XQuery query on the given XML document.For the longest treks among those with difficulty moderate, return an element node labelled trek with i) attribute child name that contains the name of the trek and ii) an element child labelled rating that has the text of the rating of the trek as content.

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.