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)); }
static XsltInvoker With(Uri stylesheetUri, IXsltProcessor processor, Assembly callingAssembly) { if (stylesheetUri == null) { throw new ArgumentNullException("stylesheetUri"); } var resolver = new XmlDynamicResolver(callingAssembly); if (!stylesheetUri.IsAbsoluteUri) { stylesheetUri = resolver.ResolveUri(null, stylesheetUri.OriginalString); } if (processor == null) { processor = Processors.Xslt.DefaultProcessor; } ConcurrentDictionary <Uri, XsltExecutable> cache = uriCache.GetOrAdd(processor, p => new ConcurrentDictionary <Uri, XsltExecutable>()); XsltExecutable executable = cache.GetOrAdd(stylesheetUri, u => { using (var stylesheetSource = (Stream)resolver.GetEntity(stylesheetUri, null, typeof(Stream))) { return(processor.Compile(stylesheetSource, new XsltCompileOptions { BaseUri = stylesheetUri, XmlResolver = resolver })); } }); return(new XsltInvoker(executable, callingAssembly)); }
static XsltInvoker With(Uri stylesheetUri, IXsltProcessor processor, Assembly callingAssembly) { if (stylesheetUri == null) throw new ArgumentNullException("stylesheetUri"); var resolver = new XmlDynamicResolver(callingAssembly); if (!stylesheetUri.IsAbsoluteUri) { stylesheetUri = resolver.ResolveUri(null, stylesheetUri.OriginalString); } if (processor == null) { processor = Processors.Xslt.DefaultProcessor; } ConcurrentDictionary<Uri, XsltExecutable> cache = uriCache.GetOrAdd(processor, p => new ConcurrentDictionary<Uri, XsltExecutable>()); XsltExecutable executable = cache.GetOrAdd(stylesheetUri, u => { using (var stylesheetSource = (Stream)resolver.GetEntity(stylesheetUri, null, typeof(Stream))) { return processor.Compile(stylesheetSource, new XsltCompileOptions { BaseUri = stylesheetUri, XmlResolver = resolver }); } }); return new XsltInvoker(executable, callingAssembly); }
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); }