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

             } catch (ProcessorException ex) {
            throw CreateRenderException(ex);
             }
        }
        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);
        }
Example #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);
        }
Example #4
0
 public abstract IEnumerable <XPathItem> Run(XQueryRuntimeOptions options);
Example #5
0
 public abstract void Run(XmlWriter output, XQueryRuntimeOptions options);
Example #6
0
 public abstract void Run(Stream output, XQueryRuntimeOptions options);
        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();
        }
        public override void Run(XmlWriter output, XQueryRuntimeOptions options)
        {
            XmlDestination builder = new TextWriterDestination(output);

             Run(builder, options);
        }
        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);
             }
        }
Example #10
0
 public XQueryResultHandler Query(XQueryRuntimeOptions options)
 {
     return new XQueryResultHandler(this.executable, options);
 }
Example #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;
        }
Example #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);
        }
Example #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;
        }
Example #14
0
 public abstract IEnumerable<XPathItem> Run(XQueryRuntimeOptions options);
Example #15
0
 public abstract void Run(XmlWriter output, XQueryRuntimeOptions options);
Example #16
0
 public abstract void Run(Stream output, XQueryRuntimeOptions options);