ropensci / dataspice

:hot_pepper: Create lightweight schema.org descriptions of your datasets
https://docs.ropensci.org/dataspice
Other
159 stars 26 forks source link

Provide a function to export as EML XML? #80

Closed amoeba closed 3 years ago

amoeba commented 5 years ago

A colleague wanted to convert their dataspice to an EML 2.1.1 XML doc today but we couldn't figure it out without a few lines of code:

json <- jsonlite::read_json("mydataspice.json")
eml <- emld::as_emld(json)
emld::as_xml(eml)

Do we have this already in dataspice and I just missed it? If not, would it be reasonable and useful to have a function to do this? We could include emld as a soft dependency and wrap the above code (or similar) in a single function.

cboettig commented 5 years ago

We talked about doing this but I don't think we ever got around to implementing it(?) IIRC dataspice currently implements EML->dataspice but not the reverse. @annakrystalli would know better than I though

amoeba commented 4 years ago

I have a not-perfect but pretty-good dataspice->EML conversion set up going. Workflow is:

spice <- read_spice(...)
eml_doc <- as_eml(spice) # Followed by an EML::write_eml if you want XML

This produces a probably invalid EML record because of terms that don't easily crosswalk to EML without me writing tons of parsing logic. The biggest issue is that schema.org/distribution and schema.org/variableMeasured don't map well to EML because schema.org has us enter variables at the dataset level where EML associates variables with dataTable elements. To make this less painful, I've provided a warning indicating this and a a crosswalk_variables function to start the user off building an EML attributes table.