Schematron to find plural keywords

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

Schematron to find plural keywords

Post by shudson310 » Wed Dec 14, 2016 4:20 am

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: servicenow.com

shudson310
Posts: 142
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Schematron to find plural keywords

Post by shudson310 » Wed Dec 14, 2016 4:21 am

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: servicenow.com

xephon
Posts: 100
Joined: Mon Nov 24, 2014 1:49 pm
Location: Münster/Germany

Re: Schematron to find plural keywords

Post by xephon » Wed Dec 14, 2016 11:36 am

I'd search for a single 's'. Is this only related to plural 's'?
Join the DOCTALES DITA development team :arrow: https://doctales.atlassian.net/wiki

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

Re: Schematron to find plural keywords

Post by tavy » Wed Dec 14, 2016 1:49 pm

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: 142
Joined: Sat Feb 26, 2005 12:09 am
Location: USA
Contact:

Re: Schematron to find plural keywords

Post by shudson310 » Wed Dec 14, 2016 5:04 pm

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

Post Reply