First of all, download the XML file I have linked here: si-2020-10.xml. (This is a file containing a Site Index of Named Entities in the Digital Mitford Archive). Open
the file in oXygen (and don’t be concerned about the schema warnings on the file).
Work with the XPath Window set to version 3.1. Respond to the XPath
questions below in a text or markdown file, and upload to Canvas
for this assignment when you’re finished. (Please use an attachment! If you paste your
answer into the text box, canvas may munch the code formatting.) Some of these tasks are
thought-provoking, and even difficult. If you get stuck, do the best you can, and if you
can’t get a working answer, give the answers you tried and explain where they failed to get
the results you wanted. Sometimes doing that will help you figure out what’s wrong, and
even when it doesn’t, it will help us identify the difficult moments. These tasks involve
the use of path expressions and predicates, as well as the XPath function,
count()
, and there may be more than one possible answer. Consult our
introductory guide Follow the
XPath! for help with constructing your expressions.
With the Site Index XML file open in oXygen and using the XPath 3.1 browser window in oXygen, construct XPath expressions that will do the following. Be sure to give the XPath expression you used in your answer, and don’t just report your results. This way, if the answer is incorrect, we can help explain what went wrong.
<div>
elements in the document? (How many are there?)<listPerson>
elements. What XPath expression shows you all the <listPerson>
elements in the document?<div>
elements contain child <listPerson>
elements? (Use a predicate filter with square brackets [ ]
to help you.)
How many <div>
elements contain <listPerson>
elements inside?<div>
elements that contain <listPlace>
elements inside?<place>
children of the <listPlace>
elements. How many are there?//place/placeName
//place//placeName
Enter the two and inspect the results. Why does the second expression return a larger number of results than the first?element()
or *
.
So, for example, //*
returns all 32,711 elements in this document. (Try it and see.) Using this information, answer the following:
<div>
elements?<list sortKey="animals">
. How can you return all the child elements of this particular list to each of the animals? (How many are there?)@sortKey
attribute. (Our answer uses a predicate filter [ ]
.) <person>
elements in the file.
<person>
elements. How many are there? <person>
elements coded with an @sex
attribute? Use a predicate filter with [ ]
to find out and record your expression here. How many results do you see? count()
function to your previous expressions to return just a number in the XPath window*
) , and divide (with the word div
).
Try writing an expression that returns the count()
of person elements coded with @sex
attributes divided by the count()
of all the person elements. Multiply that by 100 to see a percentage: About what percentage of person elements are coded with @sex
attributes in this document?
<person>
elements coded as female with @sex="f"
.count()
function and division in XPath once again to find out the proportion of persons coded female among all the persons coded with @sex
attributes.