Example #1
0
        static SchematronInvoker With(Uri schemaUri, IXsltProcessor processor, Assembly callingAssembly)
        {
            if (schemaUri == null)
            {
                throw new ArgumentNullException("schemaUri");
            }

            var resolver = new XmlDynamicResolver(callingAssembly);

            if (!schemaUri.IsAbsoluteUri)
            {
                schemaUri = resolver.ResolveUri(null, schemaUri.OriginalString);
            }

            if (processor == null)
            {
                processor = Processors.Xslt.DefaultProcessor;
            }

            ConcurrentDictionary <Uri, SchematronValidator> cache =
                uriCache.GetOrAdd(processor, p => new ConcurrentDictionary <Uri, SchematronValidator>());

            SchematronValidator validator = cache.GetOrAdd(schemaUri, u => {
                using (var schemaSource = (Stream)resolver.GetEntity(schemaUri, null, typeof(Stream))) {
                    IXPathNavigable schemaDoc = processor.ItemFactory.CreateNodeReadOnly(schemaSource, new XmlParsingOptions {
                        BaseUri     = schemaUri,
                        XmlResolver = resolver
                    });

                    return(processor.CreateSchematronValidator(schemaDoc));
                }
            });

            return(new SchematronInvoker(validator, resolver));
        }
Example #2
0
        static SchematronInvoker With(IXPathNavigable schema, IXsltProcessor processor, Assembly callingAssembly)
        {
            if (schema == null)
            {
                throw new ArgumentNullException("schema");
            }

            if (processor == null)
            {
                processor = Processors.Xslt.DefaultProcessor;
            }

            int hashCode = XPathNavigatorEqualityComparer.Instance.GetHashCode(schema.CreateNavigator());

            ConcurrentDictionary <int, SchematronValidator> cache =
                inlineCache.GetOrAdd(processor, p => new ConcurrentDictionary <int, SchematronValidator>());

            SchematronValidator validator = cache.GetOrAdd(hashCode, i => processor.CreateSchematronValidator(schema));
            var resolver = new XmlDynamicResolver(callingAssembly);

            return(new SchematronInvoker(validator, resolver));
        }
Example #3
0
 internal SchematronResultHandler(SchematronValidator validator, SchematronRuntimeOptions options)
 {
     this.validator            = validator;
     this.options              = options;
     this.defaultSerialization = options.Serialization;
 }
 internal SchematronResultHandler(SchematronValidator validator, SchematronRuntimeOptions options)
 {
     this.validator = validator;
      this.options = options;
      this.defaultSerialization = options.Serialization;
 }
Example #5
0
 private SchematronInvoker(SchematronValidator validator, XmlResolver resolver)
 {
     this.validator = validator;
     this.resolver  = resolver;
 }
Example #6
0
 private SchematronInvoker(SchematronValidator validator, XmlResolver resolver)
 {
     this.validator = validator;
      this.resolver = resolver;
 }