private static ValidationResult Validate(ViolationCollector collector, IDocumentSchema schema, IAutomatonDocument document, IDocOp docOp) { if (schema == null) { schema = DocumentSchema.NoSchemaConstraints; } var automation = new DocOpAutomaton(document, schema); var accu = new ValidationResult[] { ValidationResult.Valid }; try { docOp.Apply(new ValidationDocOpCursor(collector, automation, accu)); } catch (IllFormedException illFormed) { return ValidationResult.IllFormed; } accu[0] = accu[0].MergeWith(automation.CheckFinish(collector)); return accu[0]; }
/// <summary> /// Creates an automaton that corresponds to the set of all possible operations /// on the given document under the given schema constraints. /// </summary> public DocOpAutomaton(IAutomatonDocument document, IDocumentSchema constraints) { _document = document; _constraints = constraints; }