Skip to content

Conversation

@peterdesmet
Copy link
Member

Aims to fix #121. The EML object returned by write_eml() is correct:

library(camtrapdp)
x <- example_dataset()
x$references <- c("ref 1", "ref 2")
eml <- write_eml(x, ".")
#> 
#> ── Writing file ──
#> 
#> • './eml.xml'
eml$additionalMetadata
#> $metadata
#> $metadata$gbif
#> $metadata$gbif$bibliography
#> $metadata$gbif$bibliography$citation
#> [1] "ref 1"
#> 
#> $metadata$gbif$bibliography$citation
#> [1] "ref 2"

Created on 2025-06-04 with reprex v2.1.1

But the XML file doesn't seem to like that the elements have the same name and coverts it to:

<additionalMetadata>
    <metadata>
      <gbif>
        <bibliography>
          <citation>ref 1</citation>
          <citation.1>ref 2</citation.1>
        </bibliography>
      </gbif>
    </metadata>
  </additionalMetadata>

I'm not sure where that occurs (EML::write_eml() or underlying xml2::write_xml()) and how to resolve this. See also ropensci/EML#351

@peterdesmet
Copy link
Member Author

The root cause is jsonlite::toJSON() in this line https://github.com/ropensci/emld/blob/d12da6660f154cec35adc5a48aa32d8cc4fb590f/R/as_xml.R#L129

library(jsonlite)
ref <- list(
  citation = "ref 1",
  citation = "ref 2"
)

jsonlite::toJSON(ref)
#> {"citation":["ref 1"],"citation.1":["ref 2"]}

Created on 2025-06-04 with reprex v2.1.1

@peterdesmet
Copy link
Member Author

Blocked by ropensci/emld#72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert project$references to EML references

2 participants