我有很多包含<h1>text</h1>的XML文档。例如:
<p>
<h1>
text-1
</h1>
a lot text
<h1>
text-2
</h1>
</p>我插入以下代码:
for $p in (1 to 351)
return <a href="{$p}">{data(doc(concat("/db/INDEX/",$p,".html"))//h1)}</a>其结果是:
<a href="2"<----this is page number >
text-1
text-2
</a>
<a href="3"<----this is page number />注意:当一个页面中有两个或多个<h1>标记时,文本显示在一个标记<a>中。
但我需要这个
<a href="2">
text-1
</a>
<a href="2">
text-2
</a>当页面中不是<h1>标记时,显示空<a>。
发布于 2014-04-20 13:24:01
不如:
for $h in collection("/db/INDEX")//h1
let $i := replace(document-uri(root($h)), ".*/(.*)\.html", "$1")
return
<a href="{$i}">{string($h)}</a>https://stackoverflow.com/questions/23181594
复制相似问题