Excluding specific XML elements from word count in Vale

Post here questions and problems related to editing and publishing DITA content.
VincentV
Posts: 8
Joined: Fri Nov 22, 2024 9:59 am

Excluding specific XML elements from word count in Vale

Post by VincentV »

Hello,

I'm working on some Vale rules to use with the terminology plugin to check terminology and other style guidelines.
I'm wondering if there's a way to exclude certain elements (like uicontrol or xref) when counting words within a sentence (or to count them as a single word regardless of their length).

So far, I only have a rule that counts all words, no matter which elements they’re in:

Code: Select all

extends: occurrence
message: "sentence too long"
scope: sentence
level: suggestion
max: 25
token: \b(\w+)\b
Is this even possible to achieve with Vale or the terminology plugin?
Thank you.
adrian_sorop
Posts: 80
Joined: Wed Jun 22, 2016 2:48 pm

Re: Excluding specific XML elements from word count in Vale

Post by adrian_sorop »

Hi,

There isn’t a direct way to exclude elements when counting words within a sentence, nor to count them as a single word.
However, there might be a workaround: the Terminology Checker skips space-preserve elements. If your elements use a style such as white-space:pre, they won’t be scanned.

If you create an alternate style that marks xref, uicontrol, etc. as space-preserve, the Terminology Checker will skip these elements.
Here is the latest documentation regarding CSS styling:
https://www.oxygenxml.com/doc/versions/ ... tyles.html

Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
VincentV
Posts: 8
Joined: Fri Nov 22, 2024 9:59 am

Re: Excluding specific XML elements from word count in Vale

Post by VincentV »

Hi Adrian,
thanks a lot – that did the trick!
That probably means those elements are excluded from all other terminology checks as well, right?
How about Schematron - is it affected too?
adrian_sorop
Posts: 80
Joined: Wed Jun 22, 2016 2:48 pm

Re: Excluding specific XML elements from word count in Vale

Post by adrian_sorop »

Great to hear!

Yes, you're right. Space preserve elements are excluded from all other terminology checks.

Schematron does not automatically ignore or skip space preserve elements.
The elements are still part of the validation process - the Schematron rules will apply to them just like to any other elements, unless you explicitly tell Schematron to treat them differently.

Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
VincentV
Posts: 8
Joined: Fri Nov 22, 2024 9:59 am

Re: Excluding specific XML elements from word count in Vale

Post by VincentV »

thanks for the clarification, that works for us!
Post Reply