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

Specification 2.1.0 #37

Merged
merged 6 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions eark_validator/cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from eark_validator.model import ValidationReport
import eark_validator.packages as PACKAGES
from eark_validator.infopacks.package_handler import PackageHandler
from eark_validator.specifications.specification import SpecificationVersion

__version__ = importlib.metadata.version('eark_validator')

Expand Down Expand Up @@ -81,6 +82,13 @@ def parse_command_line():
dest='outputVerboseFlag',
default=False,
help='Verbose reporting for selected output options.')
PARSER.add_argument('-s', '--specification_version',
nargs='?',
dest='specification_version',
default=SpecificationVersion.V2_1_0,
type=SpecificationVersion,
choices=list(SpecificationVersion),
help='Specification version used for validation. Default is %(default)s.')
PARSER.add_argument('--version',
action='version',
version=__version__)
Expand All @@ -106,15 +114,15 @@ def main():

# Iterate the file arguments
for file_arg in args.files:
_loop_exit, _ = _validate_ip(file_arg)
_loop_exit, _ = _validate_ip(file_arg, args.specification_version)
_exit = _loop_exit if (_loop_exit > 0) else _exit
sys.exit(_exit)

def _validate_ip(path: str) -> Tuple[int, Optional[ValidationReport]]:
def _validate_ip(path: str, version: SpecificationVersion) -> Tuple[int, Optional[ValidationReport]]:
ret_stat, checked_path = _check_path(path)
if ret_stat > 0:
return ret_stat, None
report = PACKAGES.PackageValidator(checked_path).validation_report
report = PACKAGES.PackageValidator(checked_path, version).validation_report
print(f'Path {checked_path}, struct result is: {report.structure.status.value}')
# for message in report.structure.messages:
print(report.model_dump_json())
Expand Down
1,729 changes: 1,729 additions & 0 deletions eark_validator/ipxml/resources/profiles/V2.1.0/E-ARK-CSIP.xml

Large diffs are not rendered by default.

408 changes: 408 additions & 0 deletions eark_validator/ipxml/resources/profiles/V2.1.0/E-ARK-DIP.xml

Large diffs are not rendered by default.

832 changes: 832 additions & 0 deletions eark_validator/ipxml/resources/profiles/V2.1.0/E-ARK-SIP.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<ns prefix="mets" uri="http://www.loc.gov/METS/" />
<ns prefix="csip" uri="https://DILCIS.eu/XML/METS/CSIPExtensionMETS"/>
<ns prefix="xlink" uri="http://www.w3.org/1999/xlink" />
<pattern id="METS_administrative_metadata_element">
<title>Use of the METS administrative metadata section.</title>
<rule context="/mets:mets/mets:amdSec">
<assert id="CSIP32" role="WARN" test="mets:digiprovMD">Sould be used to record information about preservation the standard PREMIS is used.</assert>
<report id="CSIP45" role="INFO" test="mets:rightsMD">A simple rights statement may be used to describe general permissions for the package. Individual representations should state their specific rights in their representation METS file.</report>
</rule>
<rule context="/mets:mets/mets:amdSec/mets:digiprovMD">
<assert id="CSIP33" role="ERROR" test="@ID">Mandatory, unique id for the digital provenance.</assert>
<assert id="CSIP34" role="WARN" test="@STATUS">Should be used to indicate the status of the package.</assert>
<assert id="CSIP35" role="WARN" test="mets:mdRef">Should provide a reference to the digital provenance metadata file stored in the “metadata” section of the IP.</assert>
</rule>
<rule context="/mets:mets/mets:amdSec/mets:digiprovMD/mets:mdRef">
<assert id="CSIP36" role="ERROR" test="@LOCTYPE = 'URL'">Mandatory, locator type is always used with the value “URL” from the vocabulary in the attribute.</assert>
<assert id="CSIP37" role="ERROR" test="@xlink:type = 'simple'">Attribute MUST be used with the value “simple”. Value list is maintained by the xlink standard.</assert>
<assert id="CSIP38" role="ERROR" test="@xlink:href">MUST record the actual location of the resource. This specification recommends recording a URL type filepath within this attribute.</assert>
<assert id="CSIP39" role="ERROR" test="@MDTYPE">MUST record the type of metadata at the referenced location.</assert>
<assert id="CSIP40" role="ERROR" test="@MIMETYPE">MUST record the MIME type of the referenced file.</assert>
<assert id="CSIP41" role="ERROR" test="@SIZE">MUST record the size in bytes of the referenced file.</assert>
<assert id="CSIP42" role="ERROR" test="@CREATED">MUST record the date and time the referenced file was created.</assert>
<assert id="CSIP43" role="ERROR" test="@CHECKSUM">MUST record the checksum of the referenced file.</assert>
<assert id="CSIP44" role="ERROR" test="@CHECKSUMTYPE">MUST record a value from the METS-standard which identifies the algorithm used to calculate the checksum for the referenced file.</assert>
</rule>
<rule context="/mets:mets/mets:amdSec/mets:rightsMD">
<assert id="CSIP46" role="ERROR" test="@ID">Mandatory, unique id for the rights metadata.</assert>
<assert id="CSIP47" role="WARN" test="@STATUS">Should be used to indicate the status of the package.</assert>
<assert id="CSIP48" role="WARN" test="mets:mdRef">Should provide a reference to the digital provenance metadata file stored in the “metadata” section of the IP.</assert>
</rule>
<rule context="/mets:mets/mets:amdSec/mets:rightsMD/mets:mdRef">
<assert id="CSIP49" role="ERROR" test="@LOCTYPE = 'URL'">Mandatory, locator type is always used with the value “URL” from the vocabulary in the attribute.</assert>
<assert id="CSIP50" role="ERROR" test="@xlink:type = 'simple'">Attribute MUST be used with the value “simple”. Value list is maintained by the xlink standard.</assert>
<assert id="CSIP51" role="ERROR" test="@xlink:href">MUST record the actual location of the resource. This specification recommends recording a URL type filepath within this attribute.</assert>
<assert id="CSIP52" role="ERROR" test="@MDTYPE">MUST record the type of metadata at the referenced location.</assert>
<assert id="CSIP53" role="ERROR" test="@MIMETYPE">MUST record the MIME type of the referenced file.</assert>
<assert id="CSIP54" role="ERROR" test="@SIZE">MUST record the size in bytes of the referenced file.</assert>
<assert id="CSIP55" role="ERROR" test="@CREATED">MUST record the date and time the referenced file was created.</assert>
<assert id="CSIP56" role="ERROR" test="@CHECKSUM">MUST record the checksum of the referenced file.</assert>
<assert id="CSIP57" role="ERROR" test="@CHECKSUMTYPE">MUST record a value from the METS-standard which identifies the algorithm used to calculate the checksum for the referenced file.</assert>
</rule>
</pattern>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<ns prefix="mets" uri="http://www.loc.gov/METS/" />
<ns prefix="csip" uri="https://DILCIS.eu/XML/METS/CSIPExtensionMETS"/>
<ns prefix="xlink" uri="http://www.w3.org/1999/xlink" />
<pattern id="METS_behaviorSec_element">
</pattern>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<ns prefix="mets" uri="http://www.loc.gov/METS/" />
<ns prefix="csip" uri="https://DILCIS.eu/XML/METS/CSIPExtensionMETS"/>
<ns prefix="xlink" uri="http://www.w3.org/1999/xlink" />
<pattern id="METS_descriptive_metadata_element">
<title>Use of the METS descriptive metadata section.</title>
<rule context="/mets:mets/mets:dmdSec">
<assert id="CSIP18" role="ERROR" test="@ID">Mandatory, identifier must be unique within the package.</assert>
<assert id="CSIP19" role="ERROR" test="@CREATED">Mandatory, creation date and time of the descriptive metadata in this section.</assert>
<assert id="CSIP20" role="WARN" test="@STATUS">SHOULD be used to indicated the status of the package.</assert>
<assert id="CSIP21" role="WARN" test="mets:mdRef">SHOULD provide a reference to the descriptive metadata file located in the “metadata” section of the IP..</assert>
</rule>
<rule context="/mets:mets/mets:dmdSec/mets:mdRef">
<assert id="CSIP22" role="ERROR" test="@LOCTYPE = 'URL'">The locator type is always used with the value “URL” from the vocabulary in the attribute.</assert>
<assert id="CSIP23" role="ERROR" test="@xlink:type = 'simple'">Attribute used with the value “simple”. Value list is maintained by the xlink standard.</assert>
<assert id="CSIP24" role="ERROR" test="@xlink:href">The actual location of the resource. This specification recommends recording a URL type filepath in this attribute.</assert>
<assert id="CSIP25" role="ERROR" test="@MDTYPE">Specifies the type of metadata in the referenced file. Values are taken from the list provided by the METS.</assert>
<assert id="CSIP26" role="ERROR" test="@MIMETYPE">MUST hold the IANA mime type of the referenced file.</assert>
<assert id="CSIP27" role="ERROR" test="@SIZE">MUST hold the size of the referenced file in bytes.</assert>
<assert id="CSIP28" role="ERROR" test="@CREATED">MUST hold the creation date and time of the referenced file.</assert>
<assert id="CSIP29" role="ERROR" test="@CHECKSUM">MUST hold the checksum of the referenced file.</assert>
<assert id="CSIP30" role="ERROR" test="@CHECKSUMTYPE">MUST hold a value from the METS-standard which identifies the algorithm used to calculate the checksum for the referenced file.</assert>
</rule>
</pattern>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<ns prefix="mets" uri="http://www.loc.gov/METS/" />
<ns prefix="csip" uri="https://DILCIS.eu/XML/METS/CSIPExtensionMETS"/>
<ns prefix="xlink" uri="http://www.w3.org/1999/xlink" />
<pattern id="METS_file_element">
<title>Use of the METS file section.</title>
<rule context="/mets:mets/mets:fileSec">
<assert id="CSIP59" role="ERROR" test="@ID">An xml:id identifier for the file section used for internal package references.</assert>
<assert id="CSIP60" role="ERROR" test="mets:fileGrp[@USE = 'Documentation']">All documentation pertaining to the transferred content is placed in one or more file group elements with mets/fileSec/fileGrp/@USE attribute value “Documentation”.</assert>
<assert id="CSIP113" role="ERROR" test="mets:fileGrp[@USE = 'Schemas']">All XML schemas used in the information package must be referenced from one or more file groups with `mets/fileSec/fileGrp/@USE` attribute value "Schemas".</assert>
<assert id="CSIP114" role="ERROR" test="mets:fileGrp[starts-with(@USE, 'Representations')]">A pointer to the METS document describing the representation or pointers to the content being transferred must be present in one or more file groups with `mets/fileSec/fileGrp/@USE` attribute value starting with "Representations" followed by the path to the folder where the representation level METS document is placed. For example "Representation/submission" and "Representation/ingest".</assert>
</rule>
<rule context="/mets:mets/mets:fileSec/mets:fileGrp">
<report id="CSIP61" role="INFO" test="@ADMID">ADMID attribute used.</report>
<assert id="CSIP62" role="ERROR" test="(/mets:mets[@csip:CONTENTINFORMATIONTYPE='MIXED'] or ((starts-with(@USE, 'Representations') and @csip:CONTENTINFORMATIONTYPE) or not(starts-with(@USE, 'Representations'))))">When the element "Content Information Type Specification" (CSIP4) has the value "MIXED" or the file group describes a representation, then this element states the content information type specification used for the file group. When the element "Representations file group" (CSIP114), the file group describes a representation with the `mets/fileSec/fileGrp/@USE` attribute value is starting with "Representations", then this element must state the content information type specification used for the representation.</assert>
<assert id="CSIP63" role="ERROR" test="(@csip:CONTENTINFORMATIONTYPE = 'OTHER' and @csip:OTHERCONTENTINFORMATIONTYPE) or (@csip:CONTENTINFORMATIONTYPE != 'OTHER' and not(@csip:CONTENTINFORMATIONTYPE))">When the `mets/fileSec/fileGrp/@csip:CONTENTINFORMATIONTYPE` attribute has the value "OTHER" the `mets/fileSec/fileGrp/@csip:OTHERCONTENTINFORMATIONTYPE` must state a value for the Content Information Type Specification used.</assert>
<assert id="CSIP64" role="ERROR" test="@USE">This attribute is mandatory.</assert>
<assert id="CSIP65" role="ERROR" test="@ID">This attribute is mandatory. An xml:id identifier for the file group used for internal package references. It must be unique within the package.</assert>
<assert id="CSIP66" role="ERROR" test="mets:file">The file group contains the file elements which describe the file objects.</assert>
</rule>
<rule context="/mets:mets/mets:fileSec/mets:fileGrp/mets:file">
<assert id="CSIP67" role="ERROR" test="@ID">This attribute is mandatory. An xml:id identifier for the file group used for internal package references. It must be unique within the package.</assert>
<assert id="CSIP68" role="ERROR" test="@MIMETYPE">MUST record the MIME type of the referenced file.</assert>
<assert id="CSIP69" role="ERROR" test="@SIZE">MUST record the size in bytes of the referenced file.</assert>
<assert id="CSIP70" role="ERROR" test="@CREATED">MUST record the date and time the referenced file was created.</assert>
<assert id="CSIP71" role="ERROR" test="@CHECKSUM">MUST record the checksum of the referenced file.</assert>
<assert id="CSIP72" role="ERROR" test="@CHECKSUMTYPE">MUST record a value from the METS-standard which identifies the algorithm used to calculate the checksum for the referenced file.</assert>
<report id="CSIP73" role="INFO" test="@OWNERID">A file element has an OWNERID attribute.</report>
<report id="CSIP74" role="INFO" test="@ADMID">A file element has an ADMID attribute.</report>
<report id="CSIP75" role="INFO" test="@DMDID">A file element has an DMDID attribute.</report>
<assert id="CSIP76" role="ERROR" test="mets:FLocat">The location of each external file must be defined by the file location `FLocat` element using the same rules as references for metadata files. All references to files should be made using the XLink href attribute and the file protocol using the relative location of the file.</assert>
</rule>
<rule context="/mets:mets/mets:fileSec/mets:fileGrp/mets:file/mets:FLocat">
<assert id="CSIP77" role="ERROR" test="@LOCTYPE = 'URL'">Mandatory, locator type is always used with the value “URL” from the vocabulary in the attribute.</assert>
<assert id="CSIP78" role="ERROR" test="@xlink:type = 'simple'">Attribute MUST be used with the value “simple”. Value list is maintained by the xlink standard.</assert>
<assert id="CSIP79" role="ERROR" test="@xlink:href">MUST record the actual location of the resource. This specification recommends recording a URL type filepath within this attribute.</assert>
</rule>
</pattern>
</schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<ns prefix="mets" uri="http://www.loc.gov/METS/" />
<ns prefix="csip" uri="https://DILCIS.eu/XML/METS/CSIPExtensionMETS"/>
<pattern id="METS_header_element">
<title>Use of the METS header</title>
<rule context="/mets:mets/mets:metsHdr">
<assert id="CSIP7" role="ERROR" test="@CREATEDATE">The metsHdr element MUST have a CREATEDATE attribute.</assert>
<assert id="CSIP8" role="WARN" test="@LASTMODDATE">The metsHdr element SHOULD have a LASTMODDATE attribute.</assert>
<assert id="CSIP9" role="ERROR" test="@csip:OAISPACKAGETYPE">The metsHdr element MUST have a csip:OAISPACKAGETYPE attribute.</assert>
<assert id="CSIP10" role="ERROR" test="mets:agent">The metsHdr element MUST contain an agent element that records the software used to create the package.</assert>
<assert id="CSIP11" role="ERROR" test="count(mets:agent[@ROLE = 'CREATOR']) > 0">The agent element MUST have a ROLE attribute with the value "CREATOR".</assert>
</rule>
<rule context="/mets:mets/mets:metsHdr/mets:agent[@ROLE = 'CREATOR']">
<assert id="CSIP12" role="ERROR" test="@TYPE = 'OTHER'">The agent element MUST have a TYPE attribute with the value "OTHER".</assert>
<assert id="CSIP13" role="ERROR" test="@OTHERTYPE = 'SOFTWARE'">The agent element MUST have a OTHERTYPE attribute with the value "SOFTWARE".</assert>
<assert id="CSIP14" role="ERROR" test="mets:name">The agent element MUST have a child name element that records the name of the software tool used to create the IP.</assert>
<assert id="CSIP15" role="ERROR" test="mets:note">The agent element MUST have a child note element that records the version of the tool used to create the IP.</assert>
<assert id="CSIP16" role="ERROR" test="mets:note[@csip:NOTETYPE='SOFTWARE VERSION']">The mandatory agent element’s note child has a @csip:NOTETYPE attribute with a fixed value of “SOFTWARE VERSION”.</assert>
</rule>
</pattern>
</schema>
Loading
Loading