ropensci / EML

Ecological Metadata Language interface for R: synthesis and integration of heterogenous data
https://docs.ropensci.org/EML
Other
98 stars 33 forks source link

Adding funding info rearranges output and causes errors #299

Closed karawoo closed 4 years ago

karawoo commented 4 years ago

Sorry about the messy issue, had a keyboard mishap 😳

I'm trying to figure out how to add funding info to a dataset, but it seems that when I do that, it causes some reordering of the otherwise-fine elements that causes errors:

library("EML")

dataset1 <- list(
  title = "foo",
  creator = as_emld(person("Kara", "Woo")),
  pubDate = 2020,
  intellectualRights = "CC-0",
  contact = as_emld(person("Kara", "Woo")),
  abstract = "An abstract"
)

eml1 <- list(dataset = dataset1)
write_eml(eml1, "test1.xml")
eml_validate("test1.xml")
#> [1] TRUE
#> attr(,"errors")
#> character(0)

## Add funding info
dataset2 <- c(dataset1, list(funding = list(para = "Info about funding")))

eml2 <- list(dataset = dataset2)
write_eml(eml2, "test2.xml")
eml_validate("test2.xml")
#> [1] FALSE
#> attr(,"errors")
#> [1] "Element 'abstract': This element is not expected. Expected is one of ( references, alternateIdentifier, shortName, title )."

Created on 2020-03-10 by the reprex package (v0.3.0.9001)

If I look at the resulting XML files, all of the elements are there but they have been reordered so <title> is no longer first, and the validation complains.

I'm not sure if the way I'm adding funding info is correct, I couldn't find it documented, so do let me know if there's a better way. The <funding> section of the EML document looks fine to me though, so I'm wondering if there's some other issue causing this ordering problem?

karawoo commented 4 years ago

Whoops, just realized that funding belongs within the project module, so this shouldn't be valid anyway. Sorry for the noise!