Page 1 of 1

Searching for topics that are missing the target

Posted: Mon Jun 05, 2023 8:52 pm
by jmorales
Is there a way to search for all the topics that are missing something particular? For example, all topics that don't have a shortdesc element, or that don't include a particular piece of text.
Thanks!

Re: Searching for topics that are missing the target

Posted: Tue Jun 06, 2023 3:21 am
by chrispitude
Hi jmorales,

You could use XPath/XQuery Builder to search your .dita files for a particular XQuery expression.

For example, to find all top-level topics that have a <body> but not a <shortdesc> element, you could search for:

Code: Select all

/*[body][not(shortdesc)]
This identifies topics by elements that have a <body> element.

To find all topics that don't contain a certain phrase (case-insensitive),

Code: Select all

/(topic|concept|task|reference)[not(.//text()[matches(., 'some phrase', 'i')])]
This identifies topics by element name.

If you have other specific queries you'd like to perform, feel free to ask!

Re: Searching for topics that are missing the target

Posted: Tue Jun 06, 2023 8:34 pm
by jmorales
Thanks, chrispitude! That's very helpful. I'd already done some experimenting, but Xpath is not my strong point, so originally I wasn't able to come up with anything workable. However, your examples work very well.