Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
 internal SchematronResultHandler(SchematronValidator validator, SchematronRuntimeOptions options)
 {
     this.validator            = validator;
     this.options              = options;
     this.defaultSerialization = options.Serialization;
 }
Ejemplo n.º 4
0
 internal SchematronResultHandler(SchematronValidator validator, SchematronRuntimeOptions options)
 {
     this.validator = validator;
      this.options = options;
      this.defaultSerialization = options.Serialization;
 }
Ejemplo n.º 5
0
 private SchematronInvoker(SchematronValidator validator, XmlResolver resolver)
 {
     this.validator = validator;
     this.resolver  = resolver;
 }
Ejemplo n.º 6
0
 private SchematronInvoker(SchematronValidator validator, XmlResolver resolver)
 {
     this.validator = validator;
      this.resolver = resolver;
 }