8.5 Tools to help you

Both the EML and the meta file are XML files. XML stands for extensible Markup Language and is a human- and machine-readable format to store and transport data. The general structure of XML files is a hierarchical tree consisting of a root element and an unlimited number of sub-elements of different levels, as well as attributes and text. For an extensive description on how to build XML files, see the tutorial of the W³ schools.

To create the two XML files needed for the Darwin Core Archive, you do not have to be an expert in XML. In R, there are several packages that facilitate the creation of XML and even more specific, EML files, for example emld (Boettiger et al., 2020), EML (Boettiger & Jones, 2022) and xml2 (Wickham, Hester, et al., 2023).

Additionally, you can find a nice overview over packages and helpful websites to build EML files in R on the website of the LivingNorwayR package.

8.5.1 EML.xml file

The key for creating the EML.xml file are lists. The content of every EML term has to be stored as a character in a list. If terms consist of subterms, they have to be stored in nested lists within the list of the parent term (see example box below). For a full example, you can also browse our GitHub repository.

Bud burst:

keyword and keywordThesaurus are the EML subterms of keywordSet, which looks like this in XML:

<keywordSet>
  <keyword>bud burst</keyword>
  <keyword>trees</keyword>
  <keyword>ecology</keyword>
  <keyword>plant phenology</keyword>
  <keywordThesaurus>envThes</keywordThesaurus>
</keywordSet>
<keywordSet>
  <keyword>oak</keyword>
  <keywordThesaurus>GEMET</keywordThesaurus>
</keywordSet>

The lists of all terms have to be combined in a final list that can then be converted into an XML file through the function write_eml() of the EML package. Some EML terms require XML attributes (see EML terms). These can be assigned using the xml2 package by first identifying all nodes for which the attribute should be set (xml2::xml_find_all()) and then setting the attribute with xml2::xml_set_attr()).

Bud burst:

The following example shows how the final list is converted into the EML file and how to set the attribute “provider” for the taxonID.

Once you set all required attributes, you should check whether your EML file is schema-valid. This can be done with the function eml_validate() of the emld package.

References

Boettiger, C., & Jones, M. B. (2022). EML: Read and write ecological metadata language files. https://docs.ropensci.org/EML/
Boettiger, C., Jones, M. B., & Mecum, B. (2020). Emld: Ecological metadata as linked data. https://docs.ropensci.org/emld/
Wickham, H., Hester, J., & Ooms, J. (2023). xml2: Parse XML. https://xml2.r-lib.org/