Open atn38 opened 5 years ago
Hi @atn38
EML v 1.99.0 relies on nested, named lists to structure a valid EML document. I haven't reproduced your example, but I imagine adding your own named lists that are not within the EML schema to your EML document is confusing the parser that converts your list of EML to valid xml. You can add multiple geographic coverages as an unnamed list just fine (same with creator).
You can confirm that your document is valid before writing it by using the function eml_validate
if you are not doing so already
Thanks @jeanetteclark.
setting names
to NULL for the list that gets assigned to geographicCoverage
solves the problem. Didn't seem like anything to do with my own list or EML schema, but that some prior processing left a named list. eml_validate
didn't mention anything relevant to this issue.
I'm glad you found a solution!
Regarding the schema - what you have done by adding an arbitrarily named list (your list of geo coverages) into your EML is generate schema-invalid metadata. eml_validate
will catch this and show the validation errors. Below I included an MRE of your issue showing how eml_validate
catches it:
library(EML)
contacts <- list(individualName = list(givenName = "Jeanette", surName = "Clark"))
covs <- list(`1` = list(geographicDescription = "description one",
boundingCoordinates = list(westBoundingCoordinate = 120,
eastBoundingCoordinate = 121,
northBoundingCoordinate = 12,
southBoundingCoordinate = 13)),
`2` = list(geographicDescription = "description two",
boundingCoordinates = list(westBoundingCoordinate = -120,
eastBoundingCoordinate = -121,
northBoundingCoordinate = -12,
southBoundingCoordinate = -13)))
my_eml <- list(packageId = "id", system = "system",
dataset = list(
title = "A Mimimal Valid EML Dataset",
creator = contacts,
contact = contacts,
coverage = list(geographicCoverage = covs))
)
eml_validate(my_eml)
#> [1] FALSE
#> attr(,"errors")
#> [1] "Element 'geographicCoverage': Character content other than whitespace is not allowed because the content type is 'element-only'."
#> [2] "Element 'geographicCoverage': Missing child element(s). Expected is one of ( geographicDescription, references )."
Hey @cboettig,
I've got a EML list object created in EML v 1.99.0 with multiple geographicCoverage elements (more than 2 in fact):
EML$dataset$coverage$geographicCoverage
write_eml(EML, file = "file.xml")
however only takes the last element in list above and outputs<geographicCoverage>list(eastBoundingCoordinate = "-119.7155", northBoundingCoordinate = "34.0444984", southBoundingCoordinate = "34.0444984", westBoundingCoordinate = "-119.7155")Santa Cruz Island, Twin Harbor West reef: Twin Harbor West Reef is located on the north shore of Santa Cruz Island, in the Santa Barbara Channel Islands, CA. Depth ranges from -3.0 to -15 meters. Twin Harbor West Reef is located on the north shore of Santa Cruz Island, in the Santa Barbara Channel Islands, CA. Depth ranges from -3.0 to -15 meters. </geographicCoverage>
Edit: on closer inspection, in fact this happens whenever there are named lists assigned to an element (in this case just 1, 2, etc). I've got the same issue with the creator element, while unitList with unnamed list shows up fine.