Schematron: wrap consecutive uicontrol elements

Post here questions and problems related to editing and publishing DITA content.
pieterjan_vdw
Posts: 41
Joined: Wed Jun 20, 2018 11:30 am

Schematron: wrap consecutive uicontrol elements

Post 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?
tavy
Posts: 365
Joined: Thu Jul 01, 2004 12:29 pm

Re: Schematron: wrap consecutive uicontrol elements

Post 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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
pieterjan_vdw
Posts: 41
Joined: Wed Jun 20, 2018 11:30 am

Re: Schematron: wrap consecutive uicontrol elements

Post by pieterjan_vdw »

Hi Octavian,

This was indeed very complex.
Thanks for the suggestion.

Kind regards,
PJ
Post Reply