Page 1 of 1

Schematron: wrap consecutive uicontrol elements

Posted: Fri Apr 24, 2020 6:31 pm
by pieterjan_vdw
Hi,

I would like to add a Schematron rule to check consecutive uicontrol elements and suggest to use menucascade.
I have a problem when a space is added between two <uicontrol> elements.
When the file is indented like this it does work:

Code: Select all

<p><uicontrol/> <uicontrol/></p>
When it's indented like in below example it doesn't not work.
In author mode in Oxygen a space is added, but this is not visible in the text mode.

Code: Select all

		<p><uicontrol/>
<uicontrol/>
</p>
This is my code right now

Code: Select all

	<sch:pattern id="uicontrol-menuscascade">
		<sch:rule id="uicontrol" context="uicontrol[not(ancestor::menucascade)]">
			<sch:report test="starts-with(following::text()[1][normalize-space()], ' > ') or starts-with(concat(following-sibling::text()[1][normalize-space()][matches(., '^\s', ';j')],following-sibling::node()[1][contains(.,uicontrol)]), ' ')"/>
		</sch:rule>
	</sch:pattern>
How should I change it to make it work?

Re: Schematron: wrap consecutive uicontrol elements

Posted: Mon Apr 27, 2020 3:48 pm
by tavy
Hello,

I don't understand all the usecase of your rule. Maybe it is easier if you check the number of uicontrol elements, something like this:

Code: Select all

<sch:pattern id="uicontrol-menuscascade">
    <sch:rule id="uicontrol" context="uicontrol[not(ancestor::menucascade)]">
        <sch:report test="count(parent::node()/uicontrol) > 1">
            Wrap consecutive uicontrol elements
        </sch:report>
    </sch:rule>
</sch:pattern>
Best Regards,
Octavian

Re: Schematron: wrap consecutive uicontrol elements

Posted: Tue Apr 28, 2020 12:05 pm
by pieterjan_vdw
Hi Octavian,

This was indeed very complex.
Thanks for the suggestion.

Kind regards,
PJ