[Bug 5829] [FTUC] xquery full text use case document has WRONG xpath solutions

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5829





--- Comment #8 from Pat Case <pcase@crs.loc.gov>  2008-08-12 20:45:13 ---
XQuery solutions for Sections 11-17. Pat

11.2.1 Q1 Query in Same Instance of an Element
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $subj := $book/metadata/subjects/subject
where $subj ftcontains "web site" ftand "usability"
return $book

11.2.2 Q2 no change

11.2.3 Q3 Query in Every Instance of an Element (Universal Quantification)
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
where every $pub in $book//publisher satisfies 
   $pub ftcontains "ersatz" ftand "publications"
return $book
--Removed parentheses.

11.2.4 Q4 Occurrence Count Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $cont := $book//content
where $cont ftcontains "expert review methods" 
   occurs at least 2 times
return $book

12.2.1 Q1 Unordered Distance Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $cont := $book//content
where $cont ftcontains "software" ftand "developer" 
   with stemming distance at most 3 words
return $book

12.2.2 Q2 Ordered Distance Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $cont := $book//content
where $cont ftcontains "efficient" ftand "task" ftand 
   "completion" ordered distance at most 10 words
return $book

12.2.3 Q3 Ordered Window Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $cont := $book//content
where $cont ftcontains "users" ftand "feeling" ftand 
   ("well served" ftor "well-served") with stemming 
   ordered window 15 words
return $book

12.2.4 Q4 Unordered Within a Sentence Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $cont := $book//content
where $cont ftcontains "users" ftand "would" ftand "know" 
   ftand "step" with stemming same sentence
return $book

12.2.5 Q5 Unordered Within a Paragraph Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $cont := $book//content
where $cont ftcontains "usability" ftand "web site" 
   ftand "efficiency" ftand "satisfaction" same paragraph
return $book

13.2.1 Q1 Query on Element and Its Children
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $para := $book//p
let $fn := $para/footnote
where $para ftcontains "computer workstation" 
   and $fn ftcontains "comfortable"
return ($book/metadata/title, $para)

13.2.2 Q2 Query on Element Returning Its First Two Children
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $para := $book//chapter/p
where $para ftcontains "usability" ftand "test" 
   with stemming
return ($book/metadata/title, $para/step[1], $para/step[2])

13.2.3 Q3 Query on Element and Its Ancestors
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book[@number="3"]
let $comp := $book/content/part/component/
   (subComponent|subComponent/subsubComponent)/
   componentTitle
let $parentComp := $comp[ancestor::node()
where $comp ftcontains "flow diagram.?" 
   with wildcards and $parentComp [. /content/
   part/component/
   (subComponent|subComponent/subsubComponent)/
   componentTitle ftcontains "human computer 
   interaction"]
return ($book/metadata/title, $book/content)

13.2.4 Q4 Query on Element and Its Right Siblings
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $chapters := $book//chapter
where $chapters [./p ftcontains "usability 
   testing" and ./p/following-sibling::p ftcontains 
   "information architecture"]
return ($book/metadata/title, $chapters)

14.2.1 Q1 Distance Query Ignoring Content of All Descendant Elements
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $p := $book//p 
where $p ftcontains "testing" ftand "guidance" ftor 
   "correct" distance at most 60 words without content *
return $book
--Removed parentheses.

14.2.2 Q2 Phrase Query Ignoring Content of Descendant Element Specified by
XPath Expression
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $chap := $book//chapter
where $chap ftcontains "users can be tested at any 
   computer workstation or in a lab" without content 
   .//footnote] 
return ($book/metadata/title, $chap)

14.2.3 Q3 Phrase Query Ignoring Content of Descendant Element Specified by
Full-Text Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $chap := $book//chapter 
where $chap ftcontains  "at any computer workstation 
   or in a lab" without content (.//footnote[. ftcontains 
   "workstation." with wildcards])
return ($book/metadata/title, $chap)

14.2.4 Q4 Distance Query Ignoring Content of Descendant Elements Level by Level
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $where := $book//chapter/(p|p/footnote)
where $where ftcontains "workstation" ftand "lab" 
   distance at most 6 words without content ./footnote
return ($book/metadata/title, $where)
--Shortened xpath in let statement.

15.2.1 Q1 Query on Words and Phrases in Two Languages
no change

15.2.2 Q2 Phrase and Distance Query in an Instance of an Element with Stemming
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $para := $book/content//p
where $para ftcontains ("task" ftand "performance" 
   with stemming distance at most 3 words) ftand 
   "expert review" with stemming
return ($book/metadata/title, $book//content)

15.2.3 Q3 Nested Distance Query with Wildcards, Stemming, and Thesaurus Support
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $quote := $book//content
where $quote ftcontains (("millicent" 
   ftand "marigold" ordered distance at most 3 words)
   ftand "quote.{0-5}" with wildcards with thesaurus at  
   "http://bstore1.example.com/UsabilityThesaurus.xml"
   relationship "synonyms" distance at most 3 words) 
   ftand "usability testing" ftand "iterations" with stemming 
   distance at most 50 words
return $book

15.2.4 Q4 Window Query with Wildcards and Stemming Ignoring Content of a
Descendant Element
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $au := $book/metadata/author
let $co := $book//content
where $au ftcontains ftnot ("montana" ftand "marigold")
   and $co ftcontains "correct" ftor "comment" with 
   stemming ftor "guidance" ftor "assistance" 
   ftor "help" ftand "usability test.*" with wildcards 
   window 80 words without content .//footnote
return &lt;book number="{$book/@number}"&gt; 
          {$book/metadata/title, 
          $book//content}
          &lt;/book&gt;
--Removed 3 sets of parentheses in 2nd ftcontains.

15.2.5 Q5 Query on Different Elements in Different Sub-Trees with Conditional
Return
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $title := $book/metadata/title
let $in := $book/content/introduction
let $pin := $book/content/part/introduction
where $title ftcontains "usability" and $in ftcontains 
   "satisfaction" and $pin ftcontains "identify 
   problems"
return &lt;book number="{$book/@number}"&gt; 
          {$title} 
          if (count($book/metadata/author) &gt; 0)
          then {$book/metadata/author, $in, $pin}
          else {$book/metadata/publicationInfo/publisher, $in, $pin}
          &lt;/book&gt; 

16.2.1  Q1 Full-Text Query Constructing New Element
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $var := $book/metadata/title
where $var ftcontains "usability"
return &lt;result&gt; 
          {$book/metadata/title, $book/metadata/author} 
           &lt;/result&gt;

16.2.2 Q2 Full-Text Query Returning Count of Descendant Element Occurrences
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $ct := $book/content/part/chapter/title
where $ct ftcontains "usability" ftand "test" 
   with stemming
return &lt;book number="{$book/@number}"&gt; 
          {$book/metadata/title,
          for $title in $ct
          return 
             ($title, 
             &lt;number-of-steps&gt; 
                {count($title/..//step)}
             &lt;/number-of-steps&gt;)}
       &lt;/book&gt;
 --Removed parentheses on "test" with stemming

16.2.3 no change

16.2.4 no change

16.2.5 Q5 Full-Text Query with Character String Query
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book[.//publicationInfo/place/text() 
   = "Washington, D.C."]
let $intro := $book/content/introduction
where $intro ftcontains "résumés" diacritics sensitive
   ftand "drafts" ftand "correspondence"
return &lt;book number="{$book/@number}"&gt; 
           {$book/metadata/title, $intro}
           &lt;/book&gt;
--Removed parentheses around résumés" diacritics sensitive

16.2.6 no change

16.2.7 Q7 Full-Text Query with Date Comparison and Element Occurrence Count
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book[./metadata/publicationInfo/dateIssued &gt; 
   "2000-12-31" or ./metadata/publicationInfo/dateRevised 
   &gt; "2000-12-31" and count(./metadata/author) &gt; 1]
let $subj := $book//subject
where $subj ftcontains "usability test.*" with wildcards
return &lt;book number="{$book/@number}"&gt; 
          {$book/metadata/title, $book/metadata/author, $subj}
           &lt;/book&gt;
--Removed parentheses.

16.2.8 no change.

16.2.9 Q9 Query Using an XQuery Expression to Determine the Number of Words
Allowed in a Window
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $cont := $book/content
where $cont ftcontains ("successfully" 
   ftand "completing" ftand "tasks"
   window (count(./part/chapter) * 3) 
   words) with stemming
return ($book/metadata/title, $cont)
--Moved parentheses.

17.2.1-17.2.5 no change.

17.2.6 Q6 Query with Weight Declaration
for $book in doc("http://bstore1.example.com/full-text.xml")
   /books/book
let $booktext := $book/content ftcontains ("conduct" 
   ftand "usability" ftand "tests" distance at most 
   10 words) with stemming 
let score $s := $booktext ftcontains 
   ("measuring" ftand "success" distance
   at most 4 words weight 0.8) with stemming 
order by $s
return ($book/metadata/title, $booktext)
--Not sure of this one. Added parentheses.


-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Tuesday, 12 August 2008 20:45:51 UTC