This function allows you to add an ORCID or reference ID to a creator in EML.

add_creator_id(eml, orcid = NULL, id = NULL, surname = NULL)

Arguments

eml

(eml) EML file to modify.

orcid

(character) ORCID in the format 'https://orcid.org/WWWW-XXXX-YYYY-ZZZZ'.

id

(character) Reference ID for creators with additional roles (e.g., metadataProvider).

surname

(character) Creator surname. Defaults to first creator if not specified. Not case-sensitive.

Details

The function invisibly returns the full EML, which can be saved to a variable. It also prints the changed creator entry so that it is easy to check that the appropriate change was made. In addition to the EML, at least one of either the ORCID or reference ID is required.

Note: Updated creator information cannot be used as a reference for associatedParties because the extra "role" field is required. Also, the function does not (yet) account for cases in which multiple creators have the same surname.

Examples

# NOT RUN {
eml_path <- file.path(system.file(package = "datamgmt"), "dummy_meta_full.xml")
eml <- EML::read_eml(eml_path_original)
add_creator_id(eml, orcid = "https://orcid.org/WWWW-XXXX-YYYY-ZZZZ")

eml <- eml %>%
           add_creator_id(surname = "high-stakes",
                          orcid = "https://orcid.org/0000-1234-5678-4321",
                          id = "henrietta")

# Use references to add updated contact info to Henrietta's other roles
eml@dataset@contact[[1]] <- new('contact', reference = "henrietta")
eml@dataset@metadataProvider[[1]] <- new('metadataProvider', reference = "henrietta")
# }