Maintained by: David J. Birnbaum (djbpitt@gmail.com)
Last modified:
2021-12-27T22:03:57+0000
We have uploaded to the eXist database on Obdurodon (http://obdurodon.org:8080) some of the XML files that you have been developing for your projects. There is at least one file for each project (except where prohibited by copyright), as follows:
collection('/db/course/norse')
. The collection contains
just a single document: doc('/db/course/norse/alltales.xml')
collection('/db/course/natalia')
. The collection contains
36 song files, including:doc('/db/course/natalia/Musas1-MexicanaHermose.xml')
doc('/db/course/natalia/Musas2-AlmaMia.xml')
doc('/db/course/natalia/UnCanto-Cucurrucucu.xml')
collection('/db/course/hozier')
. This collection contains
17 songs, including:doc('/db/course/hozier/fromEden-6.xml')
doc('/db/course/hozier/run-15.xml')
doc('/db/course/hozier/sedated-8.xml')
doc('/db/course/addresses')
. This collection contains 59
speeches, including:doc('/db/course/addresses/washington1_1_done.xml')
doc('/db/course/addresses/washington2_2_done.xml')
doc('/db/course/addresses/harrison1_14_done.xml')
collection('/db/course/dickinson')
. This collection
contains 90 poems, including:doc('/db/course/dickinson/1858-The-Gentian-Weaves-her-fringes-out.xml')
doc('/db/course/dickinson/1853-on-this-wondrous-sea-out.xml')
doc('/db/course/dickinson/1850-valentine-week-out.xml')
collection('/db/course/stalin')
. This collection contains
just a single document:doc('/db/course/stalin/letters_markedup_no-commentary.xml')
To see the content of the document, you may need to append something to the path. For
example, if doc('/db/course/norse/alltales.xml')
doesn’t render the
document, try doc('/db/course/norse/alltales.xml')/*
. This second
expression asks for all of the child elements of the document node, and a document
node should always have a single child element, which is the root node of the
document.
The /*
isn’t strictly required for all files in all projects, but it
is for some, and it works for all of them, so we recommending including it as a
matter of course.
Select one of these texts and spend a few minutes looking at it to familiarize yourself with its overall structure. You may use your own project text or someone else’s. Then use eXide to develop a query or set of queries to explore the text you’ve chosen, that is, to extract and format something interesting about the text. Your XQuery should be more interesting and more sophisticated than just a simple XPath to retrieve the value of a single element, but what you find interesting in the text is for you to discover. We would suggest beginning by formulating the type of question someone might really want to ask about the data and then retrieving the information you need to answer it. Once you’re getting the data you want, try to incorporate your query into a structure that lets you embed the information you’re retrieving inside valid HTML output. Bear in mind:
<p>$i</p>
outputs a
literal dollar sign and a literal letter iinside
<p>
tags, which is unlikely to be what you want. To output the value of the
variable $i
, use <p>{$i}</p>
instead.return
statement returns a single sequence. A
sequence can be a single value, such as a number or string or XML element. If you
want to return more than one item in the return
statement, you have to
treat them as a single sequence, which you can do by wrapping them in parentheses
and separating them with commas. For example, the following structure:
let $i := 1 return <h2>Here is a title</h2> <p>Here is a paragraph</p>is not allowed because it returns two things, an
<h2>
element and a <p>
element. But
let $i := 1 return (<h2>Here is a title</h2>, <p>Here is a paragraph</p>)is fine because it returns a single thing, which is a sequence of the two elements. Note that to construct the sequence you need both the parentheses and the comma between the items in the sequence.
Because the XML texts that we are using here are under development, they may be inconsistently or incompletely marked up. They are all well formed, however, which means that they can be explored with XML tools, including XQuery. Remember that some may be in namespaces, in which case your queries need to refer to elements in the correct namespace. You can remind yourself of how to declare and use a namespace in XQuery at xquery-abcs.xhtml.