xquery - 如何将纬度和经度值替换为一个元素值?
问题描述
xml 文件看起来像这样 如何实现这一点?您需要将纬度和经度的值替换为一个元素值。
例如:现有的
<Longitude>-0.30365</Longitude>
<Latitude>51.61965</Latitude>
新的一个 :
<cordinate-point>-0.30365,51.619165<cordinate-point>
解决方案
您可以使用xdmp:node-insert-before()
和xdmp:node-delete()
功能:
let $doc :- fn:doc("/uri/of/your/doc.xml")
let $long := $doc/root/Longitude
let $lat := $doc/root/Latitude
(: construct an element with text() value of the Longitude and Latitude elements :)
let $point := <cordinate-point>{string-join(($lat,$long), ",")}</cordinate-point>
return
(
(: insert a new coordinate-point element before the Longitude element :)
xdmp:node-insert-before($long, $point),
(: Remove the Longitude element :)
xdmp:node-delete($long),
(: Remove the Latitude element :)
xdmp:node-delete($lat)
)
推荐阅读
- iso - 如何将 ISO 8601 中的 totalTime 参数用于 Google 结构化数据?
- haskell - 方法重载有多少字典/参数?
- visual-studio - CMAKE Cuda/ptx 项目上的重复代码生成标志
- java - 不同大小列表的交集
- node.js - Google Cloud Storage:下载部分音频文件
- reactjs - 在组件中使用 useSelector() 的结果
- python - Python 请求 - 上传文件名中带有 UTF-8 特殊字符(如“ÄÖÜ”)的文件
- reactjs - 未处理的拒绝(TypeError):zone.filter 不是函数
- javascript - React 中兄弟姐妹的访问列表
- python - Python Pandas:在将数据框保存为 csv 之前创建文件名