Knowee
Questions
Features
Study Tools

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.

Question

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.

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

Solution

The question seems to be asking for an XML query that will return certain information based on the provided XML document. Here's how you might do it using XQuery, a language designed to query XML data:

for $l in distinct-values(/walks/trek/location)
where not(exists(/walks/trek[location = $l and rating < 85]))
return 
  <location>
    <location_name>{ $l }</location_name>
    {
      for $t in /walks/trek[location = $l]
      return <trek>{ data($t/@name) }</trek>
    }
  </location>

This XQuery script does the following:

  1. It iterates over all distinct location values in the XML document.
  2. For each location, it checks if there exists a trek in that location with a rating less than 85. If such a trek exists, the location is skipped.
  3. If no such trek exists, it creates a new location element.
  4. Inside this location element, it creates a location_name element with the name of the location.
  5. It then iterates over all treks in the current location, creating a trek element for each one with the name of the trek as its text content.

The result of this query will be a series of location elements, each containing a location_name element and one or more trek elements, for all locations where no trek has a rating less than 85.

This problem has been solved

Similar Questions

Consider the following XML document and answer the questions below.1234567891011121314<WebServiceResponse>  <status>OK</status>  <result>   <type>Building</type>   <name>Dreese Labs</name>   <location>    <lat>40.002382</lat>    <lng>-83.015958</lng>   </location>  </result> <result>  <message>CSE Department</message> </result> </WebServiceResponse>What are the tags in this XML document?What are the text strings in this XML document?What are the attributes for each tag in this XML document?

On dispose d'un ensemble de fichier XML de meme nature, voici un extrait de l'un de ces fichiers:<A><B><E></E><D><F></F><G></G></D><D><G></G></D></B><B><E></E><D></D></B><B></B><C></C><D><F></F><G></G></D><B><E></E><D><G></G></D></B></A>les elements A et B ont un prix (toujours), un age (parfois). Les elements D ont une couleur. Leselements G ont une couleur toujours noire et parfois un prix.proposez une DTD en vous inspirant de cela

<?xml version = "1.0” encoding = "UTF-8"? > <doc> <a> <b> <a/> <a/> </b> <b> <a/> </b> <b> <a/> <a> <b/> <b/> </a > <a/> </b> </a> </doc> Convert each of the following queries into the corresponding XPath expression, and evaluate it on the tree by listing the pre-identifier of the nodes returned. i. For every element child m of some element node, and for every node n that is the third among all b-labelled element children of m, return the node that is the second among all element children for some descendant-or-self node of n.

What is wrong with the following XML code:<?xml version="1.0"?><!-- The following describes a car --><manufacturer>Holden</manufacturer><model>Astra</model><manufacture_date><year>2021</year><month>January</month><day>13</day></manufacture_date>Group of answer choicesThe <!-- The following describes a car --> line is not permissibleThere is not root nodeThere is no indentationThe manufacture_date tag should have been closed before opening the year tag

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.

1/2

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.