Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EML seems to have trouble with foreign key constraints #349

Open
RobLBaker opened this issue Jul 12, 2023 · 2 comments
Open

EML seems to have trouble with foreign key constraints #349

RobLBaker opened this issue Jul 12, 2023 · 2 comments

Comments

@RobLBaker
Copy link

Hello! I have an example xml file containing EML that contains a foreign key constraint. When I use EML::read_eml() followed by EML::eml_validate(), it fails to validate the file (even though it validates using https://knb.ecoinformatics.org/emlparser/). After exporting the R object to .xml using EML::write_eml(), the .xml file now fails to validate using https://knb.ecoinformatics.org/emlparser/.

If I remove the foreign key constraints, the file validates in R and the newly exported .xml file also validates using the knb tool.

I suspect that R/EML is introducing invalid eml when importing to R, that these error cause the EML to fail to validate using EML::eml_validate and that the errors are then persist when the file is written back to .xml.

image

 meta<-EML::read_eml("foreign_key_metadata.xml", from="xml")
 EML::eml_validate(meta)
[1] FALSE
attr(,"errors")
[1] "Element 'entityReference': This element is not expected. Expected is one of ( constraintDescription, key )."
[2] "Element 'entityReference': This element is not expected. Expected is one of ( constraintDescription, key )."

If I then write the R-object back to .xml, it fails to parse using the knb.ecoinformatics parser:

EML::write_eml(meta, file="foreign_key_export.xml")

image

Unfortunately, github doesn't support uploading/attaching .xml files, but I am happy to supply the original file via email for the purposes of testing and replication.

@mbjones
Copy link
Member

mbjones commented Jul 12, 2023

Thanks for the report, @RobLBaker . Can you put a code snippet of the FK section of your document in the issue here, or provide a link to the file to test against please?

@RobLBaker
Copy link
Author

I'll look into ways to share the whole file but for the time being here are the constraints:

<constraint>
     <foreignKey>
          <constraintName>FK_Org_Code_Project_ID</constraintName>
          <key>
               <attributeReference>Results.Org_Code</attributeReference>
               <attributeReference>Results.Project_ID</attributeReference>
          </key>
          <entityReference>Projects</entityReference>
     </foreignKey>
</constraint>
<constraint>
     <foreignKey>
          <constraintName>FK_Org_Code_Location_ID</constraintName>
          <key>
               <attributeReference>Results.Org_Code</attributeReference>
               <attributeReference>Results.Location_ID</attributeReference>
          </key>
          <entityReference>Locations</entityReference>
     </foreignKey>
</constraint>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants