Schematron to find plural keywords

Here should go questions about transforming XML with XSLT and FOP.
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Schematron to find plural keywords

Post by shudson310 »

I've found a few instances where an author has used something like

Code: Select all

<keyword keyref="display"/>s
.

I know this will create issues with the content is translated, or potentially if the value of the key changes.

Any suggestions on how to detect this construction? I've tried variations on substring-after, but can't get it exactly right.

Thanks!
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Schematron to find plural keywords

Post by shudson310 »

shudson310 wrote:I've found a few instances where an author is trying to create a plural version of an existing term, using something like:

Code: Select all

<keyword keyref="display"/>s
.

I know this will create issues with the content is translated, or potentially if the value of the key changes.

Any suggestions on how to detect this construction? I've tried variations on substring-after, but can't get it exactly right.

Thanks!
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
xephon
Posts: 140
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: Schematron to find plural keywords

Post by xephon »

I'd search for a single 's'. Is this only related to plural 's'?
stefan-jung.org – Your DITA/DITA-OT XML consultant
tavy
Posts: 365
Joined: Thu Jul 01, 2004 12:29 pm

Re: Schematron to find plural keywords

Post by tavy »

Hello,

You can create a Schematron rule that matches the keyword element, and check that the text after the element does not start with the 's' character. The rule will be something like this:

Code: Select all


<sch:rule context="keyword[@keyref]">
<sch:report test="following-sibling::node()[1][self::text()][starts-with(self::text(), 's')]">
The 's' character is not allowed after a keyword
</sch:report>
</sch:rule>
Or, if you want to create a more generic rule that will check if after the keyword element is not a character that might appear in a word (so you can permit "punctuation" or "space"), you can create a rule like this:

Code: Select all


<sch:rule context="keyword[@keyref]">
<sch:report test="following-sibling::node()[1][self::text()][matches(self::text(), '^\w+')]">
Text not allowed after keyword
</sch:report>
</sch:rule>
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
shudson310
Posts: 156
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Schematron to find plural keywords

Post by shudson310 »

Thanks, Octavian! The first suggestion is exactly what I needed.
Scott Hudson
Staff Content Engineer
Site: docs.servicenow.com
Post Reply