本文整理匯總了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);
}