NewtFire logo: a mosaic rendering of a firebelly newt
newtFire {dh}
Creative Commons License Last modified: Sunday, 27-Feb-2022 02:26:49 UTC. Maintained by: Elisa E. Beshero-Bondar (eeb4 at psu.edu). Powered by firebellies.

A number of student project files have been uploaded as collections to our eXist-dB XML database on newtfire. We will be working with some of these collections in this series of exercises.Go to the newtfire eXist in a web browser, and click on the eXide button to bring up a window to open files and write XQuery. This is also a review or orientation to XPath, so you should read and study the XPath Tutorial as you proceed.

  1. In an XML database, we need to identify the collections or files we are working with first. On the File menu at the top left of eXide, go to File and Open and scroll around to find the project directories for our class:
  2. Let’s start in the smashtiers collection. Open up the one file in the collection and inspect the XML to get a sense of how its data is organized using elements and attributes. Also, notice how the eXide window displays the filepath address in the database: /db/smashtiers/supersmashtierlist.xml.
  3. We will start with a query in XPath on the smashtiers XML document. Go to File >> New XQuery to start an XQuery. Paste in this document function to access the Smashtiers document and press the Eval button to see a view of it in the return window:
    doc('/db/smashtiers/supersmashtierlist.xml')//*
  4. We only want to see the char elements if they are associated with game 3. For this we will need to write an XPath predicate to filter for only the results we want. Read/review XPath predicates on our Follow the XPath tutorial where we show you some examples. The predicate inside the square brackets sets a condition that needs to be true in order for the node before the square brackets to be returned. The predicate expression is defined in relation to the node it is filtering. Work out a predicate expression to filter the char elements only if are in game number 3. That is, the char element must contain a child game element with an @n value of "3". In your text file, record your predicate expression, or record what you tried and note how many results you retrieve.
  5. When you have filtered the char elements to return a shorter list of results (those in game 2), you can also step down from those results to return other kinds of information, like the value of the attribute @id on char. To return attribute values in XQuery is a little tricky, however. You will see a number of results returned, but no actual values if you just step down to the attribute node. Follow this with ! string() or ! data() to view the attribute values. Record your expression and the number of results.

When you have completed the assignment copy and paste your expressions into a text file. Upload your text file containing your XPath and XQuery expressions to Canvas.