Schematron: wrap consecutive uicontrol elements

pieterjan_vdw
Posts: 27
Joined: Wed Jun 20, 2018 11:30 am

Schematron: wrap consecutive uicontrol elements

Post by pieterjan_vdw » Fri Apr 24, 2020 6:31 pm

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?

tavy
Posts: 219
Joined: Thu Jul 01, 2004 12:29 pm

Re: Schematron: wrap consecutive uicontrol elements

Post by tavy » Mon Apr 27, 2020 3:48 pm

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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

pieterjan_vdw
Posts: 27
Joined: Wed Jun 20, 2018 11:30 am

Re: Schematron: wrap consecutive uicontrol elements

Post by pieterjan_vdw » Tue Apr 28, 2020 12:05 pm

Hi Octavian,

This was indeed very complex.
Thanks for the suggestion.

Kind regards,
PJ

Post Reply