2

我有 2 个单独的 XML 文件,如下所示。第一个 XML 文档只包含一个标签。

<office>HeadOffice</office>

第二个文件:

 <Data>
    <location>
        <city>London</city>
        <country>England</country>
        <region>Europe</region>
    </location>
    <services>
        <consulting>SAP</consulting>
        <industry>Oil</industry>
    </services>
 </Data>

我想做的是将第一个文档(单个标签)插入到第二个 XML 文档中,使其结果如下。请注意,第一个文档仅插入标签内。

 <Data>
    <location>
        <city>London</city>
        <country>England</country>
        <region>Europe</region>
        <office>HeadOffice</office>
    </location>
    <services>
        <consulting>SAP</consulting>
        <industry>Oil</industry>
    </services>
 </Data>

不幸的是,我不能为此使用 XQuery Update Facility 规范,即我不能使用:

insert node<office>HeadOffice</office> into $data/location

我该怎么做呢?除了使用“插入节点”方法之外,我似乎找不到任何东西。任何帮助将不胜感激。

干杯杰伊

4

1 回答 1

2

您可以编写一个类型转换转换,它将以您想要的方式将两者组合成一个新文档。例如看看:https ://en.wikibooks.org/wiki/XQuery/Typeswitch_Transformations

于 2017-08-12T15:16:56.137 回答