Beispiel #1
0
        public XPathItem Compile(XPathItem stylesheet, string processor)
        {
            CompiledStylesheetReference reference;

            if (stylesheet.IsNode)
            {
                IXsltProcessor proc = (processor != null) ?
                                      Processors.Xslt[processor]
               : this.CurrentXsltProcessor ?? Processors.Xslt.DefaultProcessor;

                int hashCode;

                XsltInvoker.With((XPathNavigator)stylesheet, proc, null, out hashCode);

                if (processor == null)
                {
                    return(this.ItemFactory.CreateAtomicValue(hashCode, XmlTypeCode.Integer));
                }

                reference = new CompiledStylesheetReference {
                    HashCode  = hashCode,
                    Processor = processor
                };
            }
            else
            {
                Uri stylesheetUri = StylesheetAsUri(stylesheet);

                if (processor == null ||
                    processor == Processors.Xslt.Default)
                {
                    return(this.ItemFactory.CreateAtomicValue(stylesheetUri.ToString(), XmlTypeCode.String));
                }

                XsltInvoker.With(stylesheetUri, processor);

                reference = new CompiledStylesheetReference {
                    Uri       = stylesheetUri.AbsoluteUri,
                    Processor = processor
                };
            }

            return(this.ItemFactory
                   .CreateDocument(reference)
                   .CreateNavigator());
        }
Beispiel #2
0
        public XPathItem Compile(XPathItem stylesheet, string processor)
        {
            CompiledStylesheetReference reference;

             if (stylesheet.IsNode) {

            IXsltProcessor proc = (processor != null) ?
               Processors.Xslt[processor]
               : this.CurrentXsltProcessor ?? Processors.Xslt.DefaultProcessor;

            int hashCode;

            XsltInvoker.With((XPathNavigator)stylesheet, proc, null, out hashCode);

            if (processor == null) {
               return this.ItemFactory.CreateAtomicValue(hashCode, XmlTypeCode.Integer);
            }

            reference = new CompiledStylesheetReference {
               HashCode = hashCode,
               Processor = processor
            };

             } else {

            Uri stylesheetUri = StylesheetAsUri(stylesheet);

            if (processor == null
               || processor == Processors.Xslt.Default) {

               return this.ItemFactory.CreateAtomicValue(stylesheetUri.ToString(), XmlTypeCode.String);
            }

            XsltInvoker.With(stylesheetUri, processor);

            reference = new CompiledStylesheetReference {
               Uri = stylesheetUri.AbsoluteUri,
               Processor = processor
            };
             }

             return this.ItemFactory
            .CreateDocument(reference)
            .CreateNavigator();
        }