Page 1 of 1
Determining Elements that Exceed a Given Word Count
Posted: Tue Mar 01, 2022 6:24 am
by HSBOracle
Is there a way to query the topics in a ditamap to see if a particular element exceeds a certain number of words? For example, identify all of the shortdesc (short description) elements that contain more than 40 words? Thanks, Scott
Re: Determining Elements that Exceed a Given Word Count
Posted: Tue Mar 01, 2022 5:58 pm
by xephon
Hi,
You should create a Schematron rule and validate your map. The Schematron rule should use the document() function to step into all topics and validate the <shortdesc> elements.
Best regards
Re: Determining Elements that Exceed a Given Word Count
Posted: Wed Mar 02, 2022 12:57 am
by chrispitude
Hi HSBOracle,
As xephon suggests, you can do this by implementing a Schematron check. I would implement it by extending Oxygen's default DITA topic framework, then associating a new Schematron check file as a default check for DITA topic files:
oxygen_word_count.png
Here is a small testcase that demonstrates this approach:
oxygen_count_words_in_shortdesc.zip
When you run
Validate and Check for Completeness on a map, the word count check will be applied to all topics. In addition, because the
Automatic validation checkbox is checked in the validation scenario list, the word count check is also applied interactively in topic editing windows.
Re: Determining Elements that Exceed a Given Word Count
Posted: Wed Mar 02, 2022 9:36 am
by Radu
Hi,
Or use Oxygen's XPath Bulder view (main menu Window->Show view) having as "Scope" the current DITA Map hierarchy and using an XPath like:
Code: Select all
//shortdesc[count(tokenize(normalize-space(text()), '\s+')) > 40]
Regards,
Radu