Skip to content

01 add data

Gabi Keane edited this page Mar 22, 2023 · 9 revisions

00 review

In section 00 start here we cover initial app setup, installing the application to your local instance of eXist-db, and VSCode syncing.

Directory structures

Could you keep all of your data and code in the root directory of your application? Yes, you could, and your app would still work provided you wrote your file paths correctly. Technically, we could write the whole app in just a handful of files. But what happens when you forget a file name for something you need to edit? Or if you receive an error that doesn't include a line number on a file that contains 25 different features? What if you make a change to one line of code, and it breaks something else you didn't anticipate?

If directory structure isn't strictly required for app function, we understand that organization is important for human readability and developer experience. This principle in software development is called “separation of concerns”. We will talk in more detail about this concept in later stages, but for now we want to highlight that keeping our data (the XML files, in our case) separate from other pieces of the app lays some important informational groundwork for later.

If you set create_directory_structure to true in your properties during initial eXistentializer set up, then you already have a data directory set up.

In VSCode …

Once you’re sure that your sync is set up correctly, you can open a zsh or bash shell directly in VSCode. You can also work directly in terminal as well if that's what you're comfortable with, but check that your sync is established or expect to rebuild and reinstall your app frequently.

image

Adding data

If you're ready to make an edition, you probably already have your data living somewhere else on your filesystem. The best way to move it over is to simply copy it. We'll create some directories and copy the files over using the shell terminal you just opened.

A note on copying data

In our experience, we found inconsistencies and errors in our data while creating the app that required us to edit a dataset we hoped would be stable. You may find your XML modeling doesn't quite suit your research questions as well as you thought it would, and that may require changes to your markup that result in significant changes to the data. Pick one data set to become the single source of truth and make changes only to that data directory (either the original or the app data). If you find a need to maintain both directories, mirror the changes by copying and writing over the secondary directory each time you make a change. Consistency and documentation are key!

  1. Change to the data directory with cd data
  2. Make a new directory using mkdir your-directory-name. We used hoax_xml for our main data.
  3. Change to the directory you just created with cd your-directory-name. In our case that command looks like cd hoax_xml
  4. Now we can use cp, the copy command, to copy our data from the directory it currently lives in. For us that looks like: cp ~/Desktop/pr-app/data/hoax_xml/*.xml .

The formatting for cp is cp source-path destination-path. In this case the destination is the current directory, so we just use a dot to represent that.

We return to the data directory and repeat the same steps for our aux_xml and schemas directories.

Clone this wiki locally