installation

remotes::install_github("ropenscilabs/taxadc")
library("taxadc")
library("xml2")

simple darwin core

out <- darwin_simple(type = "PhysicalObject",
  modified = "2009-02-12", language = "en",
  basisOfRecord = "PreservedSpecimen", taxonID = "12345",
  scientificName = "Poa annua")
xml <- darwin_as_xml(out)
xml_structure(xml)
#> <SimpleDarwinRecordSet [schemaLocation, xmlns, xmlns:dc, xmlns:dwc, xmlns:xsi]>
#>   <SimpleDarwinRecord>
#>     <type>
#>       {text}
#>     <modified>
#>       {text}
#>     <language>
#>       {text}
#>     <basisOfRecord>
#>       {text}
#>     <taxonID>
#>       {text}
#>     <scientificName>
#>       {text}
write_xml(xml, (f <- tempfile(fileext=".xml")))
readLines(f, n = 2)
#> [1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"                                                                                                                                                                                                                                                                                 
#> [2] "<SimpleDarwinRecordSet xmlns=\"http://rs.tdwg.org/dwc/xsd/simpledarwincore/\" xmlns:dc=\"http://purl.org/dc/terms/\" xmlns:dwc=\"http://rs.tdwg.org/dwc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/xsd/simpledarwincore/ ../../xsd/tdwg_dwc_simple.xsd\">"

Meta