SO中文参考
首页
(current)
程序语言
c
java
python
c++
go
javascript
swift
c#
操作系统
linux
ubuntu
centos
unix
数据库
oracle
mysql
mongodb
postgresql
框架
node.js
angular
react-native
avalon
django
twisted
hadoop
.net
移动开发
android
ios
搜索
在 XQuery 中计算不同的多个值TCP/IP 图解</ti...</desc> <question vote="0"> <p>给出下面的 XML 文档。这个 XML 文档包含很多书籍。书籍可以由许多作者撰写: *</p> <pre><code>`<bib> <book year="1994"> <title>TCP/IP Illustrated</title> <author> <last>Stevens</last> <first>W.</first> </author> <publisher>Addison-Wesley</publisher> <price>65.95</price> </book> <book year="1992"> <title>Advanced Programming in the UNIX Environment</title> <author> <last>Stevens</last> <first>W.</first> </author> <publisher>Addison-Wesley</publisher> <price>39.95</price> </book> <book year="2000"> <title>Data on the Web</title> <author> <last>Abiteboul</last> <first>Serge</first> </author> <author> <last>Buneman</last> <first>Peter</first> </author> <author> <last>Suciu</last> <first>Dan</first> </author> <publisher>Morgan Kaufmann Publishers</publisher> <price>39.95</price> </book> <book year="1999"> <title>The Economics of Technology and Content for Digital TV</title> <publisher>Kluwer Academic Publishers</publisher> <price>129.95</price> </book> </bib>` </code></pre> <ul> <li></li> </ul> <p>我想从这个文档中输出没有重复的作者数量。</p> <p>我尝试过以下方法:</p> <pre><code>let $x:= distinct-values(doc('biblio.xml')//author/(first, last)) return count ($x) </code></pre> <p>但是不幸的是,这个查询没有给我预期的输出。</p> </question> <answer tick="false" vote="0"> <p>您可以按 <pre><code>author</code></pre> 和 <pre><code>first</code></pre> 元素对 <pre><code>last</code></pre> 元素进行分组,然后对组进行计数:</p> <pre><code>(for $author in //author group by $first := $author/first, $last := $author/last return $author[1]) => count() </code></pre> </answer> <answer tick="false" vote="0"> <p>尝试将 xpath 表达式更改为</p> <pre><code>distinct-values(//author/concat(last, first)) </code></pre> <p>应该根据您的样本输出<pre><code>4</code></pre></p> </answer> </body></html>
问题描述
投票:0
回答:0
xml
xquery
xquery-3.0
最新问题
浏览器 Django 上未设置 cookie,我有一个 cookie 起作用的函数,而另一个则不起作用,为什么?
此小部件已被卸载,因此状态不再具有上下文(并且应被视为已失效)。 -- 应用程序来自后台后
在 Svelte Kit 中仅加载一次数据以及何时使用 page.js 与 layout.js 加载数据
部署在uWSGI服务器上的Django应用程序的用户定义的日志变量
如何将“com.google.android.gms.fitness.service.FitnessSensorService”移植到Google Health?
使用 Django 和 HTMX 时无法更新两个元素
如何使用python正确打印unicode字符?
如何在 KMM 或 KMP 项目中检索设备唯一 ID、构建 ID 等
rvictl 不工作
枚举类可以嵌套吗?
无法在 GCP 上创建 MIG
如何在 Angular 中自定义日期格式?
Meshlab 中点云的表面网格
Swift 包管理器静态库问题
为什么React Router的元素使用箭头功能多次刷新页面
在 firebase storagereference 上使用 listAll() 总是会出现 onFailure
找不到通过 Homebrew 安装的 .h 文件
关于select语句中列别名设置为阿拉伯语
如何创建按时安排的 Google Cloud 任务?
如何在 PowerShell 中在 $MyInvocau.ScriptName 和 $MyInvocau.PSCommandPath 之间进行选择?
© www.soinside.com 2019 - 2024. All rights reserved.