Page 1 of 1

Schematron xpath fail only once

Posted: Mon Apr 12, 2021 1:42 pm
by madhukar
Hello,

How to stop schematron to break the loop if the context fails the first time.

How to avoid looping the context across the xml so restrict displaying same error message multiple times(as we know if one fails rest will follow).

Thanks

Re: Schematron xpath fail only once

Posted: Mon Apr 12, 2021 3:22 pm
by tavy
Hello,

I don't know exactly your use case, maybe you can give me an example of an XML document and a Schematron rule, to understand better the situation.
I think you can add the rule on a parent context, and then change the assert to fail if one of the rules is not true.

Best Regards,
Octavian

Re: Schematron xpath fail only once

Posted: Tue Apr 13, 2021 2:38 pm
by madhukar
Hello,

Below is the example posted

<xml>
<topic id="1">
<test>10</test>
</topic>
<topic id="2">
<test>10</test>
</topic>
<topic id="3">
<test>10</test>
</topic>
</xml>

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern>
<rule context="//topic/test">
<assert test=". > 5">
Value greater than 5
</assert>
</rule>
</pattern>
</schema>

Since the context will be looped thrice and will fail all the three times, can we stop looping through the entire xml if it fails the first time.

Hope this example helps to understand the context

Thanks

Re: Schematron xpath fail only once

Posted: Tue Apr 13, 2021 5:19 pm
by tavy
Hello,

I think the schema should be something like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
    <pattern>
        <rule context="xml">
            <let name="test" value="topic/test[number(text()) > 5]"/>
            <report test="$test" subject="$test[1]">
                Value greater than 5
            </report>
        </rule>
    </pattern>
</schema
Best Regards,
Octavian