gpt4 book ai didi

python - DBXML XQuery : move child to root of container

转载 作者:太空宇宙 更新时间:2023-11-04 06:00:41 25 4
gpt4 key购买 nike

我正在使用 python 中的 xquery 更新并尝试将子元素从 xml 树中拉出并将它们作为新的父元素插入 DBXML 数据库中。使用以下 xquery,我试图迭代每个子项,然后将子项插入回父集合。

for $child in collection($items)/parent/path/to/child return (
insert node $child into collection($items)
)

但是,会产生以下错误。

XmlQueryEvaluationError Error: Cannot perform an update that creates a persistent document with more than one document element, line 0, column

我也试过插入带有变量值但所有节点都已定义的 xml。产生相同的错误。

for $child in collection($items)/parent/path/to/child return (
insert node <parent><item>{$child/item}</item></parent> into collection($items)
)

最佳答案

我希望您不能使用 XQuery 更新集合。

您很可能必须提供单个文档节点或其他节点,而不是 fn:collection 作为更新语句的上下文。

您的第一条语句实际上是在说将一些 child 节点插入到集合中的每个文档节点中。

如果您只想使用 XQuery 插入新文档,我不确定这在 DBXML 中是否可行:http://docs.oracle.com/cd/E17276_01/html/intro_xml/modifyingdocuments.html

关于python - DBXML XQuery : move child to root of container,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25233147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com