【发布时间】:2019-04-09 23:33:43
【问题描述】:
在 XQuery 3.1 中,我正在构建一个 HTML 表。在一个<td> 元素中,我输出了一系列<a ref="">。
所以,目前这个简单的for:
<td>
{
for $b in collection($globalvar:URIdata)/tei:TEI/tei:text//tei:seg[@type="dep_event"
and @corresp = $a/data(@corresp)
and @xml:id != $a/data(@xml:id)]
order by $b/data(@xml:id)
return <a href="{concat($globalvar:URLdoc,$b/ancestor::tei:TEI/tei:text/@xml:id)}">{$b/data(@xml:id)}</a>
}
</td>
输出这个:
<td>
<a href="http://localhost:8081/exist/apps/deheresi/doc/MS609-0006">MS609-0006-8</a>
<a href="http://localhost:8081/exist/apps/deheresi/doc/MS609-0419">MS609-0419-5</a>
<a href="http://localhost:8081/exist/apps/deheresi/doc/MS609-0613">MS609-0613-4</a>
</td>
但我希望它输出以逗号分隔的<a href=""> 列表:
<td>
<a href="http://localhost:8081/exist/apps/deheresi/doc/MS609-0006">MS609-0006-8</a>,
<a href="http://localhost:8081/exist/apps/deheresi/doc/MS609-0419">MS609-0419-5</a>,
<a href="http://localhost:8081/exist/apps/deheresi/doc/MS609-0613">MS609-0613-4</a>
</td>
编辑:下面的作品...但没有按所需顺序输出结果,由于“基数”问题(原始文件中没有弹出),我无法让 order by $b/data(@xml:id) 使用它。
let $coll := collection($globalvar:URIdata)/tei:TEI/tei:text//tei:seg[@type="dep_event"
and @corresp = $a/data(@corresp)
and @xml:id != $a/data(@xml:id)]
let $last := count($coll)
for $b at $position in $coll
return (<a href="{concat($globalvar:URLdoc,$b/ancestor::tei:TEI/tei:text/@xml:id)}">{$b/data(@xml:id)}</a>,
if ($position ne $last) then ', ' else '')
非常感谢您的任何建议。
【问题讨论】:
标签: xquery exist-db xquery-3.0