XQuery:将 XML 文档插入第二个 XML 文档
XQuery: Inserting a XML document into a second XML document
我有 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 更新工具规范,即我无法使用:
insert node<office>HeadOffice</office> into $data/location
我该怎么做?除了使用 "insert node" 方法之外,我似乎找不到任何关于此的内容。任何帮助将不胜感激。
干杯
周杰伦
您可以编写类型切换转换,以您希望的方式将两者组合成一个新文档。例如,请查看:https://en.wikibooks.org/wiki/XQuery/Typeswitch_Transformations
我有 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 更新工具规范,即我无法使用:
insert node<office>HeadOffice</office> into $data/location
我该怎么做?除了使用 "insert node" 方法之外,我似乎找不到任何关于此的内容。任何帮助将不胜感激。
干杯 周杰伦
您可以编写类型切换转换,以您希望的方式将两者组合成一个新文档。例如,请查看:https://en.wikibooks.org/wiki/XQuery/Typeswitch_Transformations