コード例 #1
0
ファイル: SchematronInvoker.cs プロジェクト: ruo2012/myxsl
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: XsltInvoker.cs プロジェクト: skurdiukov/myxsl
        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);
        }
コード例 #4
0
ファイル: SchematronInvoker.cs プロジェクト: skurdiukov/myxsl
        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);
        }