Xquery 如何在if-then语句中包含多个函数调用或赋值
我是xquery新手,很难在网上找到更多的基础知识。我有我想要更改的现有代码,但我不知道如何在一个if-then语句中包含多个函数调用或变量赋值 假设我有这个街区Xquery 如何在if-then语句中包含多个函数调用或赋值,xquery,Xquery,我是xquery新手,很难在网上找到更多的基础知识。我有我想要更改的现有代码,但我不知道如何在一个if-then语句中包含多个函数调用或变量赋值 假设我有这个街区 if (fn:namespace-uri(.) = 'http://xmlns.oracle.com/communications/sce/dictionary/testNamespace' and //tns:CreateSalesOrder/tns:ListOfSWIOrderIO/tns:SWIOrder/tns:OrderT
if (fn:namespace-uri(.) = 'http://xmlns.oracle.com/communications/sce/dictionary/testNamespace'
and //tns:CreateSalesOrder/tns:ListOfSWIOrderIO/tns:SWIOrder/tns:OrderTypeCode/text() = 'Test Order'
and $isDefaultVersion)
then true()
else false()
如何在true()之后包含函数调用
类似这样,但我不知道确切的语法:
if (fn:namespace-uri(.) = 'http://xmlns.oracle.com/communications/sce/dictionary/testNamespace'
and //tns:CreateSalesOrder/tns:ListOfSWIOrderIO/tns:SWIOrder/tns:OrderTypeCode/text() = 'Test Order'
and $isDefaultVersion)
then true(), util:write-record('123','johndoe')
else false()
你可以写:
if (...) then (true(), util:write-record('123','johndoe')) else ...
注意括号
我从名字上怀疑
util:write-record()
是一个有副作用的函数。具有副作用的函数在XQuery中非常棘手,您需要了解特定实现如何处理它们。查询优化器总是有可能更改求值顺序,从而使副作用以意外的顺序发生,或者由于优化器决定不需要结果,因此根本不会发生特定调用。如果
是表达式,而不是语句。如果希望然后返回true()
值的序列和函数调用的结果,然后使用例如(true(),util:write record('123','johndoe'))构造一个序列。这是否有意义还不清楚,这取决于你想要返回什么样的表达式。