[oXygen-user] Schematron rule

Frank Dissinger frank.dissinger at cgs-oris.com
Wed Feb 22 07:57:15 CST 2023


HI Wendell,


Thank you very much. Works like a charm.


Regards,


Frank

------------------------------------------------------------------------
Am 22.02.2023 um 14:22 schrieb Wendell Piez:
> Frank,
>
> There is an interesting feature of Schematron's design useful in a 
> case like yours, namely that within a pattern, only one rule may apply 
> to any element, and the first rule wins.
>
> This means we can pre-empt the application of rules by writing other 
> rules.
>
> For example:
>
> <sch:pattern id="Check_LI">
>
>   <sch:rule context="*[exists(@conref)]//li | li[exists(@conref)]"/>
>   <sch:rule context="li">
>     <sch:assert test="exists(*)">li must have children</sch:assert>
>   </sch:rule>
>
> </sch:pattern>
>
> The second rule says "an li must have children". The first rule 
> intervenes for li elements that have @conref or an ancestor with 
> @conref - it does no checking so it is silent.
>
> Try it and see how it goes --
>
> Cheers, Wendell
>
>
> ------------------------------------------------------------------------
> On Wed, Feb 22, 2023 at 7:35 AM Frank Dissinger 
> <frank.dissinger at cgs-oris.com> wrote:
>
>     Hi all,
>
>
>     I need a Schemtron rule which indicates an error when <li>
>     elements do not have any child elements. No error schould be
>     indicated for <li> elements with an "conkeyref" attribute and also
>     for <li> elements which are children of any element with a
>     "conkeyref" attribute.
>
>
>     I have defined two separate rules...
>
>
>       <sch:pattern id="Check_LI2">
>         <sch:rule context="*li[not(@conkeyref)]*">
>           <sch:assert test="*">List does not contain any child
>     elements</sch:assert>
>         </sch:rule>
>       </sch:pattern>
>
>       <sch:pattern id="Check_LI3">
>         <sch:rule context="*li[not(parent::*[@conkeyref])]*">
>           <sch:assert test="*">List does not contain any child
>     elements</sch:assert>
>         </sch:rule>
>
>       </sch:pattern>
>
>
>     ... but I think I need to combine them into a single rule with an
>     OR or AND operator.
>
>
>       <sch:pattern id="Check_LI3">
>         <sch:rule context="*li[not(@conkeyref)]* *OR
>     **li[not(parent::*[@conkeyref])] *">
>           <sch:assert test="*">List does not contain any child
>     elements</sch:assert>
>         </sch:rule>
>
>       </sch:pattern>
>
>
>     However, this syntax is invalid. Can somebody help me?
>
>
>     Regards,
>
>     Frank
>
>     -- 
>
>     *Frank Dissinger*
>
>     Documentation Manager
>
>     ....................................................................
>
>     *CGS Publishing Technologies International GmbH*
>
>     *Email *frank.dissinger at cgs-oris.com | *Web* www.cgs-oris.com
>     <http://www.cgs-oris.com/>
>
>     *Address* Kettelerstr. 24 | D-63512 Hainburg | Germany
>
>     *Phone* +49 6182 9626-27 | *Fax* +49 6182 9626-99
>
>     *Commercial register* Offenbach, HRB no. 21495
>
>     *Managing directors* Bernd Rückert, Christoph Thommessen
>
>
>     https://www.cgs-oris.com/Signatur.png
>     <https://www.cgs-oris.com/signatur>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20230222/b8d811a9/attachment.htm>


More information about the oXygen-user mailing list