Validate XML metadata file
Validate an XML metadata file and retrieve a list of validation errors or a successful validation message.
This tool uses the same logic as the SDC metadata harvester to check for metadata issues. Failure of any check will result in the file being rejected by the SDC when harvested from one of the USGS repositories.
Validation checks
xml_valid
The file can be parsed, specifically by Python's standard library xml.etree.ElementTree.fromstring() function.
Issues that can cause XML parsing to fail include a newline at the beginning of the file or mismatched tags.
NOTE: A failure at this point will automatically result in all other checks showing as failed.
Error message: The file's XML is invalid.
title_present
The file contains a non-empty title element in the following location:
FGDC: idinfo/citation/citeinfo/title ISO: gmd:identificationInfo/gmd:MD_Data Identification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString
Error message: The file is missing a title.
email_contact_present
The file contains a properly formatted email contact in the following location:
FGDC: metainfo/metc/cntinfo/cntemail ISO: gmd:contact/gmd:CI_ResponsibleParty/gmd:contactInfo/gmd:CI_Contact/gmd:address/gmd:CI_Address/gmd:electronicMailAddress/gco:CharacterString
We are using python-email-validator.
Error message: The file is missing a valid email contact.
mdate_present
The file contains a metadata date in the following location and formats:
FGDC: metainfo/metd - 20210307, 202103, 2021 ISO: gmd:dateStamp/gco:Date - 2021-03-07, 20210307, 202103, 2021
Error message: The file is missing an mdate.
pid_in_file
The file contains an identifier in the following location:
FGDC: idinfo/keywords/theme/themekt/themekey NOTE: themekt must have the value 'USGS Metadata Identifier' ISO: gmd:fileIdentifier/gco:CharacterString
Error message: The file is missing a PID.
pid_in_pir_db
The file's identifier was found in the PIR (Persistent Identifier Registry).
Error message: The PID found in the file is not registered in the PIR database.
doi_present
The file contains a properly formatted DOI URL. The sources are checked in the following order:
FGDC:
- 'onlink': idinfo/citation/citeinfo/onlink
- 'lworkcit': idinfo/citation/citeinfo/lworkcit/citeinfo/onlink
- 'networkr': distinfo/stdorder/digform/digtopt/onlinopt/computer/networka/networkr
ISO:
- 'onlink': gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString
- 'networkr': gmd:distributionInfo/gmd:MD_Distribution/gmd:distributor/gmd:MD_Distributor/gmd:distributorTransferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL
For 'onlinks', URLs are prioritized according to the following rules:
- USGS DOIs (those containing 10.5066, such as doi.org/10.5066/ and doi.org/doi:10.5066
- non-USGS DOIs (those containing doi.org/, doi.org/doi:, doi:)
- a URL with usgs.gov/
For 'lworkcit', only a USGS DOI will be saved.
For 'networkr', a USGS DOI will be stored if present. Otherwise, any valid URL will be saved.
We are using Pydantic's AnyUrl class to validate URLs.
Error message: The file is missing a DOI.
Response
For a file with no validation errors, the API will return a response like the following:
{
"Success": "The file passed all validation checks."
}
A file with validation errors will have a response body like:
{
"Errors": [
"The file is missing a PID.",
"The PID found in the file is not registered in the PIR database."
]
}
Request
- Base URLhttps://data.usgs.gov (the document declares no server; this is the origin it was published from)
- Authnone declared
Request body multipart/form-data
Response
Successful Response
Changes
No recorded changes to this operation across all 1 revision of this API.