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

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

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