Html example 5 count number of entries html h1product

Info icon This preview shows pages 11–21. Sign up to view the full content.

</html>
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Example 5 (: count number of entries :) <html> <h1>Product Catalog</h1> <p>A <i>huge</i> list of {count(doc( "catalog.xml" )// product )} products.</p> </html>
Image of page 12
FLWORs For Let Where Order by Return
Image of page 13

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

XML File catalog.xml < catalog > < product dept ="WMN"> < number >557< /number > < name language ="en">Fleece Pullover< /name > < colorChoices >navy black< /colorChoices > < /product > < product dept ="ACC"> < number >563< /number > < name language ="en">Floppy Sun Hat< /name > < /product > < product dept ="ACC"> < number >443< /number > < name language ="en">Deluxe Travel Bag< /name > < /product > < product dept ="MEN"> < number >784< /number > < name language ="en">Cotton Dress Shirt< /name > < colorChoices >white gray< /colorChoices > < desc >Our <i>favorite</i> shirt!< /desc > < /product > < /catalog >
Image of page 14
Example 6 (: using the where clause :) for $prod in doc( "catalog.xml" )// product let $prodDept := $prod / @dept where $prodDept = "ACC" or $prodDept = "WM” return $prod /name <name language="en">Fleece Pullover</name>, <name language="en">Floppy Sun Hat</name>, <name language="en">Deluxe Travel Bag</name>
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Example 7 (: same example, basically :) (: intermingled for and let clauses :) let $doc := doc( "catalog.xml" ) for $prod in $doc // product let $prodDept := $prod / @dept let $prodName := $prod / name where $prodDept = "ACC" or $prodDept = "WMN“ return $prodName
Image of page 16
Example 8 (: what does this do? :) let $prods := doc( "catalog.xml" )// product for $d in distinct-values( $prods / @dept ) , $n in distinct-values( $prods [ @dept = $d ]/ number ) return < result dept=" { $d } " number=" { $n } "/> How many results? What if we just removed the first or second “distinct - values”? Could we have avoided using function distinct-values ?
Image of page 17

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Example 8 <result dept="WMN" number="557"/>, <result dept="ACC" number="563"/>, <result dept="ACC" number="443"/>, <result dept="MEN" number="784"/>
Image of page 18
Example 8 for $prod in doc( "catalog.xml" )// product let $d := $prod / @dept let $n := data( $prod / number ) return <result dept=" { $d } " number=" { $n } "/>
Image of page 19

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

XML File catalog.xml < catalog > < product dept ="WMN"> < number >557< /number > < name language ="en">Fleece Pullover< /name > < colorChoices >navy black< /colorChoices > < /product > < product dept ="ACC"> < number >563< /number > < name language ="en">Floppy Sun Hat< /name > < /product > < product dept ="ACC"> < number >443< /number > < name language ="en">Deluxe Travel Bag< /name > < /product > < product dept ="MEN"> < number >784< /number > < name language
Image of page 20
Image of page 21
This is the end of the preview. Sign up to access the rest of the document.
  • Winter '15
  • MAhmoudali
  • WMN

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern