Presentation is loading. Please wait.

Presentation is loading. Please wait.

XQuery Labs Basic Reporting Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates (952) 931-9198 M D Metadata Solutions.

Similar presentations


Presentation on theme: "XQuery Labs Basic Reporting Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates (952) 931-9198 M D Metadata Solutions."— Presentation transcript:

1 XQuery Labs Basic Reporting Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates dan@danmccreary.com (952) 931-9198 M D Metadata Solutions

2 M D Copyright 2008 Dan McCreary & Associates2 Overview Hello World XML Report HTML List Limiting Results with subsequence HTML Table HTML Table with Header HTML Table with CSS HTML Table with Row Count HTML Table with Alternate Rows Shaded HTML Table with Links Getting Next N Rows

3 M D Copyright 2008 Dan McCreary & Associates3 Term Manager Home Page /db/apps/terms/index.xhtml

4 M D Copyright 2008 Dan McCreary & Associates4 The following lines may be omitted… xquery version "1.0"; declare option exist:serialize "method=xhtml media- type=text/html omit-xml-declaration=yes indent=yes"; let $collection := ‘/db/apps/terms/data’ or let $get-uri := request:get-uri() let $app-base := substring-before(substring-after($get- uri, '/exist/rest'), '/views/') let $collection := concat($app-base, '/data')

5 M D Copyright 2008 Dan McCreary & Associates5 Basic Structure of XQuery xquery version "1.0"; let $collection := ‘/db/apps/terms/data’ return { for $term in collection($collection)/term return $term }

6 M D Copyright 2008 Dan McCreary & Associates6 HTML Ordered List … return Terms { for $term in collection($collection)/term return {$term/name/text()} }

7 M D Copyright 2008 Dan McCreary & Associates7 Returning Just the First 30 Terms Terms { for $term in subsequence(collection($collection)/term, 1, 30) return {$term/name/text()} - {$term/definition[1]/text()} } start count

8 M D Copyright 2008 Dan McCreary & Associates8 HTML Table Output Terms and Defintions Term Definition { for $term in subsequence(collection($collection)/term, 1, 30) return {$term/name/text()} {$term/definition[1]/text()} }

9 M D Copyright 2008 Dan McCreary & Associates9 Order and First Definition { for $term in subsequence(collection($collection)/term, 1, 30) order by $term/name/text() return {$term/name/text()} {$term/definition[1]/text()} } only return the first definition

10 M D Copyright 2008 Dan McCreary & Associates10 Using Cascading Style Sheets return HTML Table Terms and Defintions

11 M D Copyright 2008 Dan McCreary & Associates11 Adding “at $count” to Query { for $term at $count in subsequence(collection($collection)/term, 1, 30) return {$count} {$term/name/text()} {$term/definition[1]/text()} }

12 M D Copyright 2008 Dan McCreary & Associates12 Conditional Styling { for $term at $count in subsequence(collection($collection)/term, 1, 30) return {if ($count mod 2) then (attribute {'bgcolor'} {'Lavender'}) else ()} {$count} {$term/name/text()} {$term/definition[1]/text()} }

13 M D Copyright 2008 Dan McCreary & Associates13 Adding a Link to the Name { for $term at $count in subsequence(collection($collection)/term, 1, 30) return {if ($count mod 2) then (attribute {'bgcolor'} {'Lavender'}) else ()} {$term/name/text()} {$term/definition[1]/text()} } This will allow the use to click on a term name and jump directly to the item viewer for the terms.

14 M D Copyright 2008 Dan McCreary & Associates14 Getting N More Records let $start := xs:integer(request:get-parameter("start", "1")) let $records := xs:integer(request:get-parameter("records", "20")) let $query-base := request:get-url() … for $term at $count in subsequence(collection($collection)/term, $start, $records) return … <input type="button" onClick="parent.location='{$query-base}?start={$start - $records}&records={$records}'" value="Previous"/> <input type="button" onClick="parent.location='{$query-base}?start={$start + $records}&records={$records}'" value="Next"/>

15 M D Copyright 2008 Dan McCreary & Associates15 View Item let $id := request:get-parameter('id', '') … View Item {let $item := collection($collection)/term[name/@id = $id] return ID: {string($item/name/@id)} Term: {$item/name/text()} { for $def at $count in $item/definition return Definition {$count}: {$def/text()} volume={string($def/@volume)} } } /db/apps/terms/views/view-item.xq?id=123

16 M D Copyright 2008 Dan McCreary & Associates16 eXist Keyword Extensions All Keywords selects context nodes containing ALL of the keywords in the right-hand argument in any order. The default tokenizer is used to split the right-hand argument into single tokens, i.e. any punctuation or white spaces are used to separate the keywords and, after which, are omitted. Note also that wildcards are allowed, and keyword comparison is NOT case-sensitive. Any Keywords Similar to above, this operator selects context nodes containing ANY of the keywords in the right-hand argument. &= |=

17 M D Copyright 2008 Dan McCreary & Associates17 Search (: the search query string :) let $q := request:get-parameter('q', "") (: put the search results into memory :) let $search-results := collection($collection)//term[*/text() &= $q] let $count := count($search-results) /db/apps/terms/search/search.xq?q=test Match All Keywords All sub elements of term

18 M D Copyright 2008 Dan McCreary & Associates18 Search Results List { for $term in $search-results let $id := $term/name/@id let $term-name := $term/name/text() order by upper-case($term-name) return {$term-name} }

19 M D Copyright 2008 Dan McCreary & Associates19 Search.xhtml … Search string: Search

20 M D Copyright 2008 Dan McCreary & Associates20 Search Results

21 M D Copyright 2008 Dan McCreary & Associates21 Thank You! Please contact me for more information: Native XML Databases Metadata Management Metadata Registries Service Oriented Architectures Business Intelligence and Data Warehouse Semantic Web Dan McCreary, President Dan McCreary & Associates Metadata Strategy Development dan@danmccreary.com (952) 931-9198


Download ppt "XQuery Labs Basic Reporting Date: 9/29/2008 Dan McCreary President Dan McCreary & Associates (952) 931-9198 M D Metadata Solutions."

Similar presentations


Ads by Google