У меня есть файл XML, который выглядит, как это (упрощенный):Использования 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>
с и <pc>
с все в порядке.
Теперь определение смешанного контента легко - я думаю, что получаю это правильно. Проблема в том, что я не знаю, как токенизировать строки в 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