我有以下问题。我想通过使用baseX作为数据库来替换我的xquery-file中的一个元素的值。xquery代码如下:
let $db := doc('update.xml')
replace value of node $db//elem with 'haha'
return <result> {$db//elem/text()} </result>xml文档包含以下元素:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root xmlns:xs="http://www.w3.org/2001/XMLSchema-instance">
<check>
<ok>
<elem>test</elem>
<help></help>
</ok>
</check>
</root> 每次我想执行这个xquery时,都会抛出一个类似下面这样的错误:
Expecting 'where', 'order' or 'return' expression那么,我应该怎么做或更改,才能将元素中的文本"test“替换为"haha”呢?如果我只使用这一行代码,它可以工作,但我必须读出URL-Parameter,所以我需要更多的代码行,除了“替换...”排好队!
发布于 2012-11-28 18:04:45
let启动一个可能不直接包含update语句的flwor表达式。您必须在这两者之间放置一个return:
let $db := doc('update.xml')
return
replace value of node $db//elem with 'haha'您还可以进行任意计算,但请确保查询不会返回任何输出。
没有way to use updating statements and return a result at the same time。
https://stackoverflow.com/questions/13601782
复制相似问题