artefactual-labs / mets-reader-writer

Library to parse and create METS files, especially for Archivematica.
https://mets-reader-writer.readthedocs.io
GNU Affero General Public License v3.0
20 stars 13 forks source link

Problem: Tree or serialize() required as an arg to validate functions when METSDocument would be a nicer abstraction #41

Open ross-spencer opened 6 years ago

ross-spencer commented 6 years ago

Here, and a few other places we're asked to pass a .tree argument as mets_doc, in this case, to validate the document:

def xsd_validate(mets_doc, xmlschema=METS_XSD_PATH):
    xmlschema = get_xmlschema(xmlschema, mets_doc)
    is_valid = xmlschema.validate(mets_doc)
    error_log = xmlschema.error_log
    return is_valid, error_log

I wonder if the METSDocument itself wouldn't be a nicer abstraction to be passing around functions such as this when using this utility?

jrwdunham commented 6 years ago

@ross-spencer I agree. In fact, I think even nicer would be making .validate() an instance method of METSDocument.