当前位置: 首页>>代码示例>>C#>>正文


C# Processor.NewXQueryCompiler方法代码示例

本文整理汇总了C#中Saxon.Api.Processor.NewXQueryCompiler方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.NewXQueryCompiler方法的具体用法?C# Processor.NewXQueryCompiler怎么用?C# Processor.NewXQueryCompiler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Saxon.Api.Processor的用法示例。


在下文中一共展示了Processor.NewXQueryCompiler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenXML

    public void GenXML()
    {
        String sourceUri = Server.MapPath("5648.xml");
        String xqUri = Server.MapPath("graph.xq");

        using (FileStream sXml = File.OpenRead(sourceUri))
        {
            using (FileStream sXq = File.OpenRead(xqUri))
            {
                Processor processor = new Processor();
                XQueryCompiler compiler = processor.NewXQueryCompiler();
                compiler.BaseUri = sourceUri;
                XQueryExecutable exp = compiler.Compile(sXq);
                XQueryEvaluator eval = exp.Load();

                DocumentBuilder loader = processor.NewDocumentBuilder();
                loader.BaseUri = new Uri(sourceUri);
                XdmNode indoc = loader.Build(new FileStream(sourceUri, FileMode.Open, FileAccess.Read));

                eval.ContextItem = indoc;
                Serializer qout = new Serializer();
                qout.SetOutputProperty(Serializer.METHOD, "xml");
                qout.SetOutputProperty(Serializer.INDENT, "yes");
                qout.SetOutputProperty(Serializer.SAXON_INDENT_SPACES, "1");
                qout.SetOutputWriter(Response.Output);
                eval.Run(qout);
            }
        }
    }
开发者ID:plasma-umass,项目名称:Hound,代码行数:29,代码来源:Default.aspx.cs

示例2: run

 /// <summary>
 /// Show a query producing a document as its result and serializing this to a FileStream
 /// </summary>
 public override void run(Uri samplesDir)
 {
     Processor processor = new Processor();
     XQueryCompiler compiler = processor.NewXQueryCompiler();
     compiler.BaseUri = samplesDir.ToString();
     compiler.DeclareNamespace("saxon", "http://saxon.sf.net/");
     XQueryExecutable exp = compiler.Compile("<saxon:example>{static-base-uri()}</saxon:example>");
     XQueryEvaluator eval = exp.Load();
     Serializer qout = new Serializer();
     qout.SetOutputProperty(Serializer.METHOD, "xml");
     qout.SetOutputProperty(Serializer.INDENT, "yes");
     qout.SetOutputProperty(Serializer.SAXON_INDENT_SPACES, "1");
     qout.SetOutputStream(new FileStream("testoutput.xml", FileMode.Create, FileAccess.Write));
     Console.WriteLine("Output written to testoutput.xml");
     eval.Run(qout);
 }
开发者ID:nuxleus,项目名称:saxonica,代码行数:19,代码来源:ExamplesPE.cs

示例3: run

        public override void run(Uri samplesDir)
        {

            String query = "import schema default element namespace \"\" at \"" + samplesDir + "\\data\\books.xsd\";\n" +
                            "for $integer in (validate { doc(\"" + samplesDir + "\\data\\books.xml\") })//schema-element(ITEM)\n" +
                                "return <OUTPUT>{$integer}</OUTPUT>";
            Processor processor = new Processor();

            XQueryCompiler compiler = processor.NewXQueryCompiler();
            compiler.XQueryLanguageVersion = "1.0";
            XQueryExecutable exp = compiler.Compile(query);
            XQueryEvaluator eval = exp.Load();
            Serializer qout = new Serializer();
            eval.Run(qout);
        }
开发者ID:zhuyue1314,项目名称:xcat,代码行数:15,代码来源:ExamplesEE.cs

示例4: Main

    /**
     * Method main. First argument is the Saxon samples directory.
     */
    public static void Main(String[] argv)
    {

        String samplesDir;

        if (argv.Length > 0)
        {
            samplesDir = argv[0];
        }
        else
        {
            String home = Environment.GetEnvironmentVariable("SAXON_HOME");
            if (home == null)
            {
                Console.WriteLine("No input directory supplied, and SAXON_HOME is not set");
                return;
            }
            else
            {
                if (home.EndsWith("/") || home.EndsWith("\\"))
                {
                    samplesDir = home + "samples/";
                }
                else
                {
                    samplesDir = home + "/samples/";
                }
            }
        }

        UriBuilder ub = new UriBuilder();
        ub.Scheme = "file";
        ub.Host = "";
        ub.Path = samplesDir;
        Uri baseUri = ub.Uri;

        Console.WriteLine("Base URI: " + baseUri.ToString());

        // Create a schema-aware Processor

        Processor saxon = new Processor(true);

        // Load a schema

        SchemaManager manager = saxon.SchemaManager;
        manager.ErrorList = new ArrayList();
        Uri schemaUri = new Uri(baseUri, "data/books.xsd");

        try {
            manager.Compile(schemaUri);
        } catch (Exception e) {
            Console.WriteLine("Schema compilation failed with " + manager.ErrorList.Count + " errors");
            foreach (StaticError error in manager.ErrorList) {
                Console.WriteLine("At line " + error.LineNumber + ": " + error.Message);
            }
            return;
        }


        // Use this to validate an instance document

        SchemaValidator validator = manager.NewSchemaValidator();
        Uri instanceUri = new Uri(baseUri, "data/books.xml");
        validator.SetSource(instanceUri);
        validator.ErrorList = new ArrayList();
        XdmDestination psvi = new XdmDestination();
        validator.SetDestination(psvi);

        try {
            validator.Run();
        } catch (Exception e) {
            Console.WriteLine("Instance validation failed with " + validator.ErrorList.Count + " errors");
            foreach (StaticError error in validator.ErrorList) {
                Console.WriteLine("At line " + error.LineNumber + ": " + error.Message);
            }
        }


        // Run a query on the result to check that it has type annotations

        XQueryCompiler xq = saxon.NewXQueryCompiler();
        XQueryEvaluator xv = xq.Compile("data((//PRICE)[1]) instance of xs:decimal").Load();
        xv.ContextItem = psvi.XdmNode;
        Console.WriteLine("Price is decimal? " + xv.EvaluateSingle().ToString());

    }
开发者ID:pombredanne,项目名称:https-dev.saxonica.com-repos-archive-opensource-,代码行数:89,代码来源:SchemaExamples.cs

示例5: XQueryProcessor

 public XQueryProcessor()
 {
     _processor = new Processor();
     _compiler = _processor.NewXQueryCompiler();
 }
开发者ID:GrgDmr,项目名称:CDAManager,代码行数:5,代码来源:XQueryProcessor.cs


注:本文中的Saxon.Api.Processor.NewXQueryCompiler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。