/// <summary> /// Run the validation of the supplied source document, optionally /// writing the validated document to the supplied destination. /// </summary> public void Run() { AugmentedSource aug = AugmentedSource.makeAugmentedSource(source); aug.setSchemaValidationMode(lax ? Validation.LAX : Validation.STRICT); JReceiver receiver; if (destination == null) { receiver = new Sink(); } else if (destination is Serializer) { receiver = ((Serializer)destination).GetReceiver(config); } else { Result result = destination.GetResult(); if (result is JReceiver) { receiver = (JReceiver)result; } else { throw new ArgumentException("Unknown type of destination"); } } PipelineConfiguration pipe = config.makePipelineConfiguration(); if (errorList != null) { pipe.setErrorListener(new ErrorGatherer(errorList)); } new Sender(pipe).send(aug, receiver, true); }
/// <summary> /// Supply the instance document to be validated in the form of a Uri reference /// </summary> /// <param name="uri">URI of the document to be validated</param> public void SetSource(Uri uri) { StreamSource ss = new StreamSource(uri.ToString()); AugmentedSource aug = AugmentedSource.makeAugmentedSource(ss); aug.setPleaseCloseAfterUse(true); this.source = aug; }
/// <summary> /// Compile a schema, retrieving the source using a URI. The resulting schema components are added /// to the cache. /// </summary> /// <remarks> /// The document located via the URI is parsed using the <c>System.Xml</c> parser. /// </remarks> /// <param name="uri">The URI identifying the location where the schema document can be /// found</param> public void Compile(Uri uri) { StreamSource ss = new StreamSource(uri.ToString()); AugmentedSource aug = AugmentedSource.makeAugmentedSource(ss); aug.setPleaseCloseAfterUse(true); if (errorList == null) { config.addSchemaSource(aug); } else { config.addSchemaSource(aug, new ErrorGatherer(errorList)); } }