本文整理汇总了C#中Saxon.Api.Processor.WriteXdmValue方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.WriteXdmValue方法的具体用法?C# Processor.WriteXdmValue怎么用?C# Processor.WriteXdmValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Saxon.Api.Processor
的用法示例。
在下文中一共展示了Processor.WriteXdmValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: run
/// <summary>
/// Demonstrate XQuery Update
/// </summary>
public override void run(Uri samplesDir)
{
Processor processor = new Processor(true);
DocumentBuilder loader = processor.NewDocumentBuilder();
loader.BaseUri = new Uri(samplesDir, "data/books.xml");
loader.TreeModel = TreeModel.LinkedTree;
XdmNode indoc = loader.Build(new Uri(samplesDir, "data/books.xml"));
Console.Out.WriteLine("=========== BEFORE UPDATE ===========");
Serializer serializer0 = new Serializer();
serializer0.SetOutputProperty(Serializer.METHOD, "xml");
serializer0.SetOutputProperty(Serializer.INDENT, "yes");
serializer0.SetOutputWriter(Console.Out);
processor.WriteXdmValue(indoc, serializer0);
String query =
"for $i in //PRICE return \n" +
"replace value of node $i with $i - 0.05";
XQueryCompiler compiler = processor.NewXQueryCompiler();
compiler.UpdatingEnabled = true;
XQueryExecutable exp = compiler.Compile(query);
XQueryEvaluator eval = exp.Load();
eval.ContextItem = indoc;
XdmNode[] updatedNodes = eval.RunUpdate();
foreach (XdmNode root in updatedNodes)
{
Uri documentUri = root.DocumentUri;
if (documentUri != null && documentUri.Scheme == "file")
{
Stream stream = UriConnection.getWritableUriStream(documentUri);
Serializer serializer = new Serializer();
serializer.SetOutputProperty(Serializer.METHOD, "xml");
serializer.SetOutputProperty(Serializer.INDENT, "yes");
serializer.SetOutputStream(stream);
processor.WriteXdmValue(root, serializer);
}
}
Console.Out.WriteLine("=========== AFTER UPDATE ===========");
processor.WriteXdmValue(indoc, serializer0);
}