Validation is usually performed on an entire document. If we are only
interested in validating a single nested node that can occur in
different contexts, this would require writing different schemas for
any of those different contexts.
By temporarily replacing the document's root node, we can validate the
relevant node only.
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
}
+int
+virXMLValidateNodeAgainstSchema(const char *schemafile,
+ xmlDocPtr doc,
+ xmlNodePtr node)
+{
+ xmlNodePtr root;
+ int ret;
+
+ root = xmlDocSetRootElement(doc, node);
+ ret = virXMLValidateAgainstSchema(schemafile, doc);
+ xmlDocSetRootElement(doc, root);
+ return ret;
+}
+
+
void
virXMLValidatorFree(virXMLValidatorPtr validator)
{
int
virXMLValidateAgainstSchema(const char *schemafile,
xmlDocPtr xml);
+
+int
+virXMLValidateNodeAgainstSchema(const char *schemafile,
+ xmlDocPtr doc,
+ xmlNodePtr node);
+
void
virXMLValidatorFree(virXMLValidatorPtr validator);