什么XQuery将导致以下输出?鉴于以下XML
XML-
<build id="b0">
<dept>IE</dept>
<dept>EE</dept>
<name>alpha</name>
<type>lib</type>
<year>1000</year>
</build>
<build id="b1">
<dept>IE</dept>
<name>beta</name>
<type>teach</type>
<type>lib</type>
<year>1000</year>
</build>
预期产量
<group dept="EE" count="1"/>
<group dept="IE" count="2"/>
明智地将部门分组并打印其计数,其中年份为1000
答案 0 :(得分:0)
给出以下(更正的)[05/Dec/2018:01:45:24 +0000] rlm="" "1.0" "off" "" "/version" "GET" "" "0" "" "" "" "" "" "400" "1.361" "437" "127.0.0.1" "-" "-" "HTTP/1.1" "http" "8c645f63-cc1c-9f1b-9c65-5b51eae6aa08" "242" "710" "istiotesthelm-sentry.default.svc.cluster.local" "-" "curl/7.35.0" "-" "127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1" "-" "1311560" "disabled" "1.359" "0.000" "1.359" "200" ""
[05/Dec/2018:01:45:24 +0000] rlm="" "1.0" "off" "" "/version" "GET" "" "0" "" "" "" "" "" "400" "1.364" "437" "127.0.0.1" "-" "-" "HTTP/1.1" "http" "8c645f63-cc1c-9f1b-9c65-5b51eae6aa08" "242" "699" "istiotesthelm-sentry.default.svc.cluster.local" "-" "curl/7.35.0" "-" "127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1" "-" "369741" "disabled" "1.363" "0.000" "1.363" "200" ""
[05/Dec/2018:01:45:24 +0000] rlm="" "1.0" "off" "" "/version" "GET" "" "0" "" "" "" "" "" "400" "1.366" "437" "127.0.0.1" "-" "-" "HTTP/1.1" "http" "8c645f63-cc1c-9f1b-9c65-5b51eae6aa08" "242" "688" "istiotesthelm-sentry.default.svc.cluster.local" "-" "curl/7.35.0" "-" "127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1, 127.0.0.1" "-" "422420" "disabled" "1.365" "0.000" "1.365" "200" ""
input.xml
您可以使用此XQuery表达式/文件
<?xml version="1.0"?>
<root>
<build id="b0">
<dept>IE</dept>
<dept>EE</dept>
<name>alpha</name>
<type>lib</type>
<year>1000</year>
</build>
<build id="b1">
<dept>IE</dept>
<name>beta</name>
<type>teach</type>
<type>lib</type>
<year>1000</year>
</build>
</root>
获得以下期望的输出
let $file := doc("a.xml")
for $cur in distinct-values($file/root/build[year=1000]/dept)
order by $cur
return <group dept="{$cur}" count="{count($file/root/build/dept[. = $cur])}" />