Schematron to find plural keywords

Here should go questions about transforming XML with XSLT and FOP.
shudson310
Posts: 89
Location: USA

Schematron to find plural keywords

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
Content Strategist
Jeppesen
Site: jeppesen.com
shudson310
Posts: 89
Location: USA

Re: Schematron to find plural keywords

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
Content Strategist
Jeppesen
Site: jeppesen.com
xephon
Posts: 96
Location: Münster/Germany

Re: Schematron to find plural keywords

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: 137

Re: Schematron to find plural keywords

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: 89
Location: USA

Re: Schematron to find plural keywords

Wed Dec 14, 2016 5:04 pm

Thanks, Octavian! The first suggestion is exactly what I needed.
Scott Hudson
Content Strategist
Jeppesen
Site: jeppesen.com

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 2 guests