ebeshero / DHClass-Hub

a repository to help introduce and orient students to the GitHub collaboration environment, and to support DH classes.
GNU Affero General Public License v3.0
27 stars 27 forks source link

Date Arithmetic for Data Visualization: User-Defined Functions in XQuery #778

Closed ebeshero closed 4 years ago

ebeshero commented 4 years ago

I have been exploring the Rocket Launches project data in our newtFire eXist-db, to see about how to work with its xs:dateTime and xs:duration datatypes for use in charts and graphs. Before we can begin visualizing these data, we need to be able to survey it. A first stage was inspecting and cleaning up a few little errors in the duration datatype values, which are now ready for visualizing thanks to this team's dedicated work. The project has 124 small XML files and is helpful for modeling "date arithmetic."

To prepare the data for graphing on a screen, it needs to be converted from the complex format of the datatypes into a simpler decimal value. Here's an example file showing our input data. And here's what the datatype values look like:

I posted an XQuery script to survey the launch dates and the durations of each mission with simple text output to survey the 124 files in the Rocket Launches collection, and I wrote it using user-defined functions, that is functions you can write yourself that don't exist in the standard XPath collection. My XQuery is also posted in our newtfire eXist-db in /db/2020_ClassExamples/rocketDateDurationSurvey.xql