我有一个大文本文件,有时看起来像这样:
<w>
<randomnode>
<pa/>
<pa>
Keyword1 sometxt1 <thing>abc</thing>: blabla
</pa>
<stuff>abc</stuff>
<pa>
just blabla
</pa>
<pa>
Keyword2 othertxt2: blabla
</pa>
<pa>
just blabla
</pa>
<pa>
just blabla
</pa>
<pa>
Keyword1 xxx: and blabla
</pa>
</randomnode>
</w>
并希望得到这个结果:
<w>
<randomnode>
<k attr="keyword1 sometxt1">
<p>
<s>
Keyword1 sometxt1 <thing>abc</thing>:
</s>
blabla
</p>
<stuff>abc</stuff>
<p>
just blabla
</p>
</k>
<k attr="keyword1 othertxt2">
<p>
<s>
Keyword2 othertxt2:
</s>
blabla
</p>
<p>
just blabla
</p>
<p>
just blabla
</p>
</k>
<k attr="keyword1 xxx">
<p>
<s>
Keyword1 xxx:
</s>
and blabla
</p>
</k>
</randomnode>
</w>
<pa>
用英语:每当该节点的 text() 中有关键字 1 或关键字 2 或关键字 3 时,我想遍历它们并将它们分组。<s>
on the 内容的拆分:
是在另一个模板中完成的,一旦我可以<pa>
正确分组就应该可以工作。
到目前为止我有这个:
<xsl:for-each-group select="$randomnode/*[normalize-space(.)!='']"
group-starting-with="pa/text()[contains(., 'keyword1')
or contains(., 'keyword2') or contains(., 'keyword3')]">
问题在于没有选择任何内容,我有一种感觉是因为 text() ...
我可以在 text() 上使用 group-starting-woth 吗?在我做一些完全不同的事情之前,我真的很想使用它并扩展/纠正它。