我正在使用这个非常简单的XML文档(我从教程中借用了它),book-mod.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="WEB">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="WEB">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>并使用此查询:
copy $d := doc("books-mod.xml")
modify (
for $t in $d//title
return replace value of node $t with concat($t, " in bed")
)
return $d该查询运行并执行我所期望的(即在每个书名中附加文本“in bed”)。然而,令人惊讶的是,它也修改了源文档..。我认为使用此转换的copy的全部目的是修改文档的副本。
我在这里错过了什么?
我使用xqilla和-u来执行查询。
发布于 2012-04-17 19:54:38
你说得对,这绝对是个错误。转换表达式是显式的更新表达式。
转换表达式是一个简单的表达式,因为它不修改任何现有节点的值。
您使用的是哪个版本的XQilla?版本2.2.2的更改日志提到了一些相关的内容:
所以可能已经修好了。
https://stackoverflow.com/questions/10197736
复制相似问题