我有一个XML文件看起来像这样的个别字(simplifed):使用Schematron的快速修复标记在混合内容元素
<defs>
<def>Pure text</def>
<def>Mixed content, cuz there is also another: <element>element inside</element> and more.</def>
<def><element>Text nodes within elements other than def are ok.</element></def>
<defs>
我想写与快速修复一个Shematron规则,这将使我以混合内容的形式将每个单词放在defs中,并将它们分别包装在<w>
元素中,并在<pc>
元素中包装标点符号。换句话说,应用快速修复后,我会得到
<defs>
<def>Pure text.</def>
<def><w>Mixed</w> <w>content</w><pc>,</pc> <w>cuz</w> <w>there</w> <w>is</w> <w>also</w> <w>another</w><pc>:</pc> <element>element inside</element> <w>and</w> <w>more</w><pc>.</pc></def>
<def><element>Text nodes within elements other than def are ok.</element></def>
<defs>
<w>
S和<pc>
秒之间空间都OK。
现在,识别混合内容很简单 - 我想我得到这一权利。问题是我不知道如何标记Schematron中的字符串,然后对每个标记应用修复。这是我得到多远:
<sch:pattern id="mixed">
<sch:rule context="def[child::text()][child::*]">
<sch:report test="tokenize(child::text(), '\s+')" sqf:fix="mix_in_def">
Element has mixed content
<!-- the above this gives me the error: a sequence of more than one item is not allowed as the first argument of tokenize-->
</sch:report>
<sqf:fix id="mix_in_def">
<sqf:description>
<sqf:title>Wrap words in w</sqf:title>
<sqf:p>Fixes the mixed content in def by treating each non-tagged string as w.</sqf:p>
</sqf:description>
<sqf:replace match="." node-type="element" target="w">
<!--how do i represent the content of the matched token?-->
</sqf:replace>
<!-- also do i create an altogether separate rule for punctuation?-->
</sqf:fix>
</sch:rule>
</sch:pattern>
任何提示将不胜感激。
坦奇
我的回答对你有帮助吗? – sergioFC
我仍在等待一些反馈,请告诉我我的回答是否有用。 – sergioFC
绝对。我真的很抱歉,我没有确认你的答案。我的错。 – Tench