I am trying to create a schematron that will point out where a fig element has been wrapped around a p element. I prefer to have the p element end and then the fig element begin.
I have found a template to ensure the fig IS wrapped by the p element but I don't know how to change it to make it do the reverse.
Here is the template:
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
queryBinding="xslt2">
<sch:pattern>
<sch:rule context="*[contains(@class, ' topic/fig ') and not(contains(@class, ' topic/fig
ut-d/imagemap '))]" role="warn">
<sch:let name="precedingText" value="preceding-sibling::text()"/>
<sch:let name="followingText" value="following-sibling::text()"/>
<sch:assert test=".[parent::p][count(parent::node()/child::*) = 1]
[not($precedingText) or $precedingText[normalize-space()='']]
[not($followingText) or $followingText[normalize-space()='']]" >
The fig element should be wrapped in a paragraph.</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema>
CodePudding user response:
If you change sch:assert with sch:report you will get the reverse check. Or add the not() function around the entire XPath value of the @test attribute.