Saxon是否等效于ADO.NET/JDBC setParameter(),在其中我可以执行以下操作: var query = XPath.createQuery(“ / root / name / [@ first = @ param1]”); query.setParam(“ @ param1”,“戴夫”);
答案 0 :(得分:0)
XPath允许XPath表达式中的变量,变量引用与$varName
一起使用。因此,在具有http://saxonica.com/html/documentation/dotnetdoc/Saxon/Api/XPathCompiler.html的Saxon .NET中,您可以使用
var processor = new Processor();
var xpathCompiler = processor.NewXPathCompiler();
xpathCompiler.DeclareVariable(new QName("param1"));
var xpathSelector = xpathCompiler.Compile("/root/name/[@first = $param1]").Load();
xpathSelector.SetVariable(new QName("param1"), new XdmAtomicValue("dave"));