dbxmlxquery:将子级移动到contain的根

2024-06-20 15:13:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在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)
)

Tags: topathinnodechild元素forreturn
1条回答
网友
1楼 · 发布于 2024-06-20 15:13:15

我希望您不能使用XQuery更新集合。你知道吗

代替fn:collection作为update语句的上下文,您很可能需要提供单个文档节点或其他节点。你知道吗

您的第一条语句实际上是在集合中的每个文档节点中插入一些child节点。你知道吗

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

相关问题 更多 >