This is a guest post from Francesca Giannetti, with some notes on ways to use some advanced searching/transforming features in Oxygen with the letters we’re editing. Try the examples below with Oxygen. Then try modifying them and seeing what else you can do…
—AG
All of the XPath expressions and XSLT transformations assume the use of ainsworthwpe.xml as a source file, available to download at https://github.com/rutgersdh/wsb-data/blob/master/letters/ainsworthwpe.xml
Use the XPath toolbar!
Where is the XPath toolbar, you ask? Upper left side of the screen, under the icons. Have a look: https://www.oxygenxml.com/xml_editor/xpath.html
Try the following on the suggested WSB file.
How many letters are in this file? How many pages? Why aren’t these numbers the same? The count() function does, well, what it says it does.
count(//div[@type='letter'])
count(//pb)
Who is mentioned in the Ainsworth letters?
//body//persName
Wait. Without duplicates this time, who is mentioned? The @key attribute is being used by encoders to capture a normalized version of each person’s name, so if the letter mentions a “Pete” (Ainsworth’s nickname) we can record this as a reference to William P. E. Ainsworth. The distinct-values() function in XPath removes duplicates.
distinct-values(//body//persName/@key)
Let’s filter out Silvers and Ainsworth from that list, since they’re kind of a given as the main correspondents. Who else gets mentioned in their letters? The not() function expresses negation. We add /@key at the end of the XPath expression to run the distinct-values() function across those values, and not the filtered //body//persName values, which will be whatever is actually written in the letters (e.g. “Dad” and “George” who are the same person, namely Ainsworth’s father).
distinct-values(//body//persName[not(@key = ('Ainsworth, William Penn Esterbrook', 'Silvers, Earl Reed'))]/@key)
Which of the places mentioned in the Ainsworth letter are in France? The contains() function allows us to do a bit of string manipulation on element and attribute values. We’ve asked it to find “France” somewhere inside of the @key values (normalized place values) of the placeName elements.
//body//placeName/@key[contains(., 'France')]
Transform into HTML!
You can get a surprising amount done with the XPath language, but for more complex manipulations, and to transform TEI XML into HTML for web display, we need to move to a different X family language. Here, we’re using XSLT.
Oxygen instructions for setting up an XML transformation with XSLT: https://www.oxygenxml.com/doc/versions/24.1/ug-editor/topics/xml-transformation-with-xslt.html
We’re going to return to our question about who is mentioned in the Ainsworth letters, this time pulling a bit more information about them. Download this XSLT and put it in the same folder with ainsworthwpe.xml. In Oxygen, click on the wrench icon to configure a transformation scenario. Press New > XML Transformation with XSLT. Give this transformation a name so you can retrieve it later (suggested: People Mentioned). Next, have a look at the XML URL and XSL URL. The XML URL should be your current file (ainsworthwpe.xml), denoted with the following variable name: ${currentFileURL}. As for the XSL URL, use the folder icon to the right of the box to search for the 20220923-personography.xsl file where you saved it on your computer. Now that you’ve indicated your source file and the XSLT, tab over to the Output panel. Under Output File, select: Save as ${cfn}_personography.html (current file name without extension, then add the underscore followed by personography.html). Check the box next to Open in browser. Leave everything else unchecked. Then press OK and Apply associated. The HTML transformation will open in your default browser.
Very nice, although the editor has been sloppy with including source links.
How about a really practical transformation, showing the text of our letters for the purpose of proofreading? Download https://github.com/rutgersdh/wsb-data/blob/master/processing/wsb_html_error-checking.xsl. Set up another XSL transformation and call it Error Checking. Use the settings we used for the prior example, except name the output file ${cfn}.html in this case. The output will be a reading edition of the letters, with some color coding based on whether or not the annotation is a person, a place, or a claim.