本文整理汇总了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);
}
}
}
示例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);
}
示例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);
}
示例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();
}