对于下面的代码,它抛出一个异常。归功于order by。
Configuration config = createEnterpriseConfiguration();
Processor processor = new Processor(config);
XPathCompiler xpath = processor.newXPathCompiler();
XPathExecutable exe = xPath.compile("for $x in /Order_1/Order_2 order by $x/@id descending, $X/@name ascending return $x");它在以下情况下工作正常:
XPathExecutable exe = xPath.compile("for $x in /Order_1/Order_2 return $x");XPathException为:
Message: net.sf.saxon.trans.XPathException: expected "return", found name "order"
Location: XPath syntax error at char 27 near {...x in /Order_1/Order_2 order...}:在这种情况下,如何设置order by?
发布于 2017-11-08 22:47:12
"order by“子句在XPath中不可用,只能在XQuery中使用。
请改用XQueryCompiler。
XPath 3.0实际上有一个sort()函数,但它可能不具备足够的功能,例如,它不能处理升序和降序键的混合。
https://stackoverflow.com/questions/47166827
复制相似问题