Help:COAP-3180/hw4: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
Line 35: Line 35:
== Classroom activities ==
== Classroom activities ==


=== Open an XML file in an XML editor ===
=== Use Xquery with an XML editor ===


; Learning how to use the XML Exchanger editor:
; Learning how to use the XML Exchanger editor:
Line 56: Line 56:
* http://tecfa.unige.ch/guides/xml/examples/shakespeare.1.10.xml/ (various Shakespeare texts)
* http://tecfa.unige.ch/guides/xml/examples/shakespeare.1.10.xml/ (various Shakespeare texts)
* http://tecfa.unige.ch/proj/seed/catalog/net/xml/catalog-eng.xml (700k DITA document)
* http://tecfa.unige.ch/proj/seed/catalog/net/xml/catalog-eng.xml (700k DITA document)
=== Become somewhat familiar with eXist ===
Instructor's Web site:  http://tecfax.unige.ch:8080/exist/
(Official exist web site: http://exist.sourceforge.net/index.html)
* Launch the Java Webstart client (username = coap, password will be announced)
* Add a document to the //db/coap/coap3180 collection
* Retrieve some information with the REST interface and return it with some kind of html (browser must display it)
; Examples (make sure to retrieve the whole lines !)
See the slides (not distributed with an URL, since not good enough ... get them from the N: drive
Simple XPath query:
<pre>
http://tecfax.unige.ch:8080/exist/rest/db/shakespeare?_query=//SPEECH[SPEAKER=%22JULIET%22]&_start=1&_howmany=10
</pre>
Xquery returning some kind of HTML:
<pre>
http://tecfax.unige.ch:8080/exist/rest/db/?_wrap=no&_query=<html> <body>List of names: <ul> { for $t in document("/db/coap/cooking/dolores.xml")//recipe let $name := $t//recipe_name return <li>{$name/text()} </li> } </ul></body></html>
</pre>
Xquery returning an XML fragment.
<pre>
http://tecfax.unige.ch:8080/exist/rest/db/?_query=for $t in document("/db/coap/cooking/dolores.xml")//recipe let $name := $t//recipe_name return <name>{$name/text()} </name>
</pre>


== Reading and links ==
== Reading and links ==

Revision as of 01:20, 3 December 2007

Homework 4 - COAP 3180 Fall 2 2007

COAP 3180 Course Page

Summary

  • Write some Xquery code to retrieve data from an XML collection

Part 1

  • Find somewhere or create a file with some XML data (at least 1 page long)
  • Write at least two different XQuery expressions to retrieve data from this file

Due: Monday Week 6

Note: Programmers who wish to play with their own XML database can download eXist from source forge. Get the latest 1.1.x-newcore version, e.g. eXist-1.1.1-newcore-build4311.jar.

To install it, type in a command window: java -jar eXist-1.1.1-newcore-build4311.jar

Part 2

Variant A (ok for non programmers)
  • Create at least two XQueries that can return some kind of HTML
  • Submit them with a REST GET request
  • Keep these URLs in a file and hand them over to the instructor
Variant B
  • Create a PHP script that uses the REST API or some other library (but this may turn out to be more work than you'd expect)
  • Return a result in html (e.g. via php code, with a server-side XSLT stylesheet).

Classroom activities

Use Xquery with an XML editor

Learning how to use the XML Exchanger editor
  • Launch XML Exchanger lite.
    • In the left panel open all the files under xquery
    • Click on the bottom tab with the books.xml file
    • In the menubar select Transform->XQuery
    • Note: You can find the xq file somewhere near the same place
  • Repair the result file. There are some useless tags.
Other XML examples
  • Other examples files can be found on the N drive

Files from Essential XQuery - The XML Query Language

Also some more ambitious

Become somewhat familiar with eXist

Instructor's Web site: http://tecfax.unige.ch:8080/exist/ (Official exist web site: http://exist.sourceforge.net/index.html)

  • Launch the Java Webstart client (username = coap, password will be announced)
  • Add a document to the //db/coap/coap3180 collection
  • Retrieve some information with the REST interface and return it with some kind of html (browser must display it)
Examples (make sure to retrieve the whole lines !)

See the slides (not distributed with an URL, since not good enough ... get them from the N: drive

Simple XPath query:

 http://tecfax.unige.ch:8080/exist/rest/db/shakespeare?_query=//SPEECH[SPEAKER=%22JULIET%22]&_start=1&_howmany=10

Xquery returning some kind of HTML:

http://tecfax.unige.ch:8080/exist/rest/db/?_wrap=no&_query=<html> <body>List of names: <ul> { for $t in document("/db/coap/cooking/dolores.xml")//recipe let $name := $t//recipe_name return <li>{$name/text()} </li> } </ul></body></html>

Xquery returning an XML fragment.

http://tecfax.unige.ch:8080/exist/rest/db/?_query=for $t in document("/db/coap/cooking/dolores.xml")//recipe let $name := $t//recipe_name return <name>{$name/text()} </name>

Reading and links

Reading

Reading

Reference

You can find additional links and more tutorials here:

Slides

Prerequisites and catchup (if needed)