[public-qt-comments] <none>

in the document: "XML Query Use Cases  W3C Working Draft 16 Aug 2002"

1.1.9.7 Q7

List the titles and years of all books published by Addison-Wesley after 
1991, in alphabetic order.
Solution in XQuery:
<bib>
   {
     for $b in document("www.bn.com/bib.xml")//book
     where $b/publisher = "Addison-Wesley" and $b/@year > 1991
     return
         <book>
             { $b/@year }
             { $b/title }
         </book>
     sort by (title)
   }
</bib>
Expected Result:
<bib>
     <book year="1992">
         <title>Advanced Programming in the Unix environment</title>
     </book>
     <book year="1994">
         <title>TCP/IP Illustrated</title>
     </book>
</bib>

$b/@year is interpreted as an attribute of the <book>

1.5.4.6 Q6
List the short titles of all sections (the values of the "shorttitle" 
attributes of all "section" elements, expressing each short title as the 
value of a new element.)
Solution in XQuery:
<result>
   {
     for $s in input()//section/@shorttitle
     return <stitle>{ $s }</stitle>
   }
</result>
Expected Result:
Attribute values in start-tags on lines 23, 50, 59

If I interprete "...each short title as the value of a new element"
The result should be:

<result>
<stitle>What is markup?</stitle>
<stitle>What is SGML?</stitle>
<stitle>How does SGML work?</stitle>
</result>

Is this interpretation correct?
If yes, what makes the different interpretation of attributes in 1.1.9.7 Q7 
and1.5.4.6 Q6 ?

What is the expected result of the query:

     for $y in document("www.bn.com/bib.xml")//book/@year
     return $y

Received on Tuesday, 20 August 2002 04:17:54 UTC