diff --git a/src/core/xmlschemas.py b/src/core/xmlschemas.py index 6f9703d..2593400 100644 --- a/src/core/xmlschemas.py +++ b/src/core/xmlschemas.py @@ -232,13 +232,19 @@ class Schema(elements.Element): type.__class__ = typeClass return TypeContext(type, value, previous = value) - def validateDoc(self, doc, options): - """ Validates a libxml2 document. Returns 0 on success. + def validateDocument(self, doc, options = 0): + """ Validates a libxml2 document. Returns True on pass. """ validationContext = self._schemaContext.schemaNewValidCtxt() validationContext.schemaSetValidOptions(options) - return doc.schemaValidateDoc(validationContext) + return doc.schemaValidateDoc(validationContext) == 0 + def validateElement(self, node, options = 0): + """ Validates a libxml2 element node. Returns True on pass. + """ + validationContext = self._schemaContext.schemaNewValidCtxt() + validationContext.schemaSetValidOptions(options) + return node.schemaValidateOneElement(validationContext) == 0 class SchemaContext(stations.AbstractContext):