在xpath中,我将处理如下所示的源XML,在这里我要连接每个源XML的子元素
editor
使用空格分隔符创建全名,然后依次用逗号连接生成的全名:
<biblStruct type="book" xml:id="Biller_2011a">
<monogr>
<title>Inquisitors and Heretics in Thirteenth-Century Languedoc: Edition and Translation
of Toulouse Inquisition Depositions, 1273-1282</title>
<editor>
<forename>Peter</forename><surname>Biller</surname>
</editor>
<editor>
<forename>Caterina</forename><surname>Bruschi</surname>
</editor>
<editor>
<forename>Shelagh</forename><surname>Sneddon</surname>
</editor>
<imprint>
<pubPlace>
<settlement>Leiden</settlement>
<country>NL</country>
</pubPlace>
<publisher>Brill</publisher>
<date type="pub_date">2011</date>
</imprint>
</monogr>
</biblStruct>
当前,使用xpath的xpath(在xquery中)代码如下所示
map
引入分隔符:
let $bibref := $bib//tei:biblStruct[@xml:id="Biller_2011a"]
return <editors>{
(for $auth in $bibref//tei:editor
return normalize-space(string-join($auth//child::text()," ")))!(if (position() > 1) then ', ' else (), .)
}</editors>
但这会在逗号前后输出额外的空间:
<editors>Peter Biller , Caterina Bruschi , Shelagh Sneddon</editors>
相反,我想输出:
<editors>Peter Biller, Caterina Bruschi, Shelagh Sneddon</editors>
事先谢谢。