Esempio n. 1
0
        public void Render(TextWriter writer, XQueryRuntimeOptions options)
        {
            try {
            this.Executable.Run(writer, options);

             } catch (ProcessorException ex) {
            throw CreateRenderException(ex);
             }
        }
Esempio n. 2
0
        public override void Run(TextWriter output, XQueryRuntimeOptions options)
        {
            if (options == null) throw new ArgumentNullException("options");

             Serializer serializer = this.Processor.ItemFactory.CreateSerializer(options.Serialization);
             serializer.SetOutputWriter(output);

             Run(serializer, options);
        }
Esempio n. 3
0
        protected override void RenderView(ViewContext viewContext, TextWriter writer, object instance)
        {
            if (viewContext == null) throw new ArgumentNullException("viewContext");

             XQueryPage page = instance as XQueryPage;

             if (page == null) {
            throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Compiled view '{0}' must inherit from {1}.", this.ViewPath, typeof(XQueryPage).AssemblyQualifiedName));
             }

             page.SetIntrinsics(HttpContext.Current);
             page.AddFileDependencies();

             var options = new XQueryRuntimeOptions();
             options.ContextItem = viewContext.ViewData.Model;

             foreach (var item in viewContext.ViewData) {
            options.ExternalVariables[new XmlQualifiedName(item.Key)] = item.Value;
             }

             page.Render(viewContext.Writer, options);
        }
Esempio n. 4
0
 public abstract IEnumerable <XPathItem> Run(XQueryRuntimeOptions options);
Esempio n. 5
0
 public abstract void Run(XmlWriter output, XQueryRuntimeOptions options);
Esempio n. 6
0
 public abstract void Run(Stream output, XQueryRuntimeOptions options);
Esempio n. 7
0
        public override IEnumerable<XPathItem> Run(XQueryRuntimeOptions options)
        {
            XQueryEvaluator eval = GetEvaluator(options);

             XdmValue val;

             try {
            val = eval.Evaluate();

             } catch (DynamicError ex) {
            throw new SaxonException(ex);

             } catch (Exception ex) {
            throw new SaxonException(ex.Message, ex);
             }

             return val.ToXPathItems();
        }
Esempio n. 8
0
        public override void Run(XmlWriter output, XQueryRuntimeOptions options)
        {
            XmlDestination builder = new TextWriterDestination(output);

             Run(builder, options);
        }
Esempio n. 9
0
        void Run(XmlDestination destination, XQueryRuntimeOptions options)
        {
            XQueryEvaluator eval = GetEvaluator(options);

             try {
            eval.Run(destination);

             } catch (DynamicError ex) {
            throw new SaxonException(ex);

             } catch (Exception ex) {
            throw new SaxonException(ex.Message, ex);
             }
        }
Esempio n. 10
0
 public XQueryResultHandler Query(XQueryRuntimeOptions options)
 {
     return new XQueryResultHandler(this.executable, options);
 }
Esempio n. 11
0
        XQueryEvaluator GetEvaluator(XQueryRuntimeOptions options)
        {
            if (options == null) throw new ArgumentNullException("options");

             XQueryEvaluator eval = this.executable.Load();

             if (options.InputXmlResolver != null) {
            eval.InputXmlResolver = options.InputXmlResolver;

            XmlDynamicResolver dynamicResolver = options.InputXmlResolver as XmlDynamicResolver;

            if (dynamicResolver != null
               && dynamicResolver.DefaultBaseUri == null) {

               dynamicResolver.DefaultBaseUri = this.StaticBaseUri;
            }
             }

             if (options.ContextItem != null) {
            eval.ContextItem = options.ContextItem.ToXdmItem(this.Processor.ItemFactory);
             }

             foreach (var pair in options.ExternalVariables) {

            var qname = new QName(pair.Key);
            XdmValue xdmValue = pair.Value.ToXdmValue(this.Processor.ItemFactory);

            eval.SetExternalVariable(qname, xdmValue);
             }

             return eval;
        }
Esempio n. 12
0
        public XQueryResultHandler Query(object input, object parameters)
        {
            if (input == null) throw new ArgumentNullException("input");

             var options = new XQueryRuntimeOptions {
            ContextItem = input,
            InputXmlResolver = new XmlDynamicResolver(this.withCallingAssembly)
             };

             if (parameters != null) {

            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(parameters)) {
               options.ExternalVariables.Add(new XmlQualifiedName(property.Name), property.GetValue(parameters));
            }
             }

             return Query(options);
        }
Esempio n. 13
0
        XQueryRuntimeOptions GetRuntimeOptions(XPathItem input, IEnumerable<XPathNavigator> parameters)
        {
            var options = new XQueryRuntimeOptions();

             if (input != null) {
            options.ContextItem = input;
             }

             if (parameters != null) {

            foreach (XPathNavigator n in parameters) {
               options.ExternalVariables.Add(new XmlQualifiedName(n.Name, n.NamespaceURI), n.TypedValue);
            }
             }

             return options;
        }
Esempio n. 14
0
 public abstract IEnumerable<XPathItem> Run(XQueryRuntimeOptions options);
Esempio n. 15
0
 public abstract void Run(XmlWriter output, XQueryRuntimeOptions options);
Esempio n. 16
0
 public abstract void Run(Stream output, XQueryRuntimeOptions options);