XQuery:在保留标记的同时标记文本

XQuery:在保留标记的同时标记文本,xquery,tokenize,Xquery,Tokenize,考虑以下XQuery代码: let $foo := <root>This is a <tag>test</tag>. This is <tag>only</tag> a <tag>test</tag>.</root> for $s in tokenize($foo, "\. ") return <sentence>{$s}</sentence> 假设我想将$foo拆分成句子,

考虑以下XQuery代码:

let $foo := <root>This is a <tag>test</tag>. This is <tag>only</tag> a <tag>test</tag>.</root>
for $s in tokenize($foo, "\. ")
return <sentence>{$s}</sentence>
假设我想将$foo拆分成句子,同时保留嵌入的标记,给出如下输出:

<sentence>this is a <tag>test</tag>.</sentence>
<sentence>this is <tag>only</tag> a <tag>test</tag>.</sentence>

我应该如何解决这个问题?

我希望这就是您想要的:

let $foo := <root>This is a <tag>test</tag>. This is <tag>only</tag> a <tag>test</tag>.</root>
for $s in tokenize(xdmp:quote($foo/node()), "\. ")
return xdmp:unquote("<sentence>"||$s||"</sentence>")
let $foo := <root>This is a <tag>test</tag>. This is <tag>only</tag> a <tag>test</tag>.</root>
for $s in tokenize(xdmp:quote($foo/node()), "\. ")
return xdmp:unquote("<sentence>"||$s||"</sentence>")