How to search XML code in all my topics?

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Carl
Posts: 75
Joined: Fri Oct 19, 2018 2:19 am

How to search XML code in all my topics?

Post by Carl » Thu Dec 05, 2019 11:13 pm

This problem has vexed me ever since I started using OxygenXML: how do I search for specific XML code? For example, I want to find all occurrences of:

Code: Select all

conkeyref="corp-vars/corp"
And replace it with:

Code: Select all

conkeyref="strings-corp/corp"
I've tried different options under "Find/Replace in Files", but I can't get it to work. I have selected "Enable XML search options" and then selected all the options beneath it, but it doesn't find anything. I know that there are dozens of incorrect references in my project.

Your online help seems to give conflicting information, as it mentions deselecting "Enable XML search options" as a way to get it to search the entire file. But that doesn't work either.

Radu
Posts: 6933
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to search XML code in all my topics?

Post by Radu » Fri Dec 06, 2019 12:43 pm

Hi,

Here are a couple of ways to do this:

- Search for corp-vars/corp, set in the Restrict to XPath field the value @conkeyref to restrict the search only to this specific attribute
You can also "Enable XML Search Options" and check the "Attribute Values" checkbox but the xpath field restriction is enough to make this work.
If this still does not work for you, maybe you are not searching in the entire set of DITA resources or maybe there are no DITA resources with that particular reference inside them, so you should also look at the "Include files" filter.

- If you have the main DITA Map opened in the DITA Maps Manager view, right click there on the topic reference on which the key is defined and choose "Refactoring->Rename Key".

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Carl
Posts: 75
Joined: Fri Oct 19, 2018 2:19 am

Re: How to search XML code in all my topics?

Post by Carl » Tue Dec 10, 2019 2:44 am

Thanks Radu. I have attached a screenshot showing my Find settings. I believe I've made it as liberal as I could, yet I still get:

Scanned Files: 357
Occurrences: 0

I copied the conkeyref[/b] string directly from my topic and I know there are many many instances of this string in my project. I cannot understand why Oxygen doesn't find any of them!
Selection_067.png
Selection_067.png (32.86 KiB) Viewed 279 times
Attachments
Selection_067.png
Selection_067.png (32.86 KiB) Viewed 279 times

Radu
Posts: 6933
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to search XML code in all my topics?

Post by Radu » Tue Dec 10, 2019 11:07 am

Hi,

If you check the "Enable XML search options" checkbox the document will be split in several intervals and in each interval the text that you want to find will be searched. So as you have already checked the "Attribute names" and "Attribute values" checkboxes, you will get separate search intervals for attribute names and for attribute values, but you are searching for a string which contains both the attribute name and value and this is why the string is not found in any of the search intervals.
So please uncheck the "Enable XML search options" checkbox and use that "Restrict to XPath" filter I suggested in my initial reply.
searchWithRestrictedXPath.png
searchWithRestrictedXPath.png (21.14 KiB) Viewed 274 times
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Carl
Posts: 75
Joined: Fri Oct 19, 2018 2:19 am

Re: How to search XML code in all my topics?

Post by Carl » Wed Dec 11, 2019 3:40 am

Yes, using the "Restrict to XPath" option worked. I never would have figured this out myself--talk about non-obvious!

Can't you make a search that actually searches ALL the text in a dita topic? A simple text string search is all I need.

Radu
Posts: 6933
Joined: Fri Jul 09, 2004 5:18 pm

Re: How to search XML code in all my topics?

Post by Radu » Wed Dec 11, 2019 9:13 am

Hi Carl,
Can't you make a search that actually searches ALL the text in a dita topic? A simple text string search is all I need.
By default that dialog has the "XML Search Options" checkbox disabled so this is what it does by default, it does simple text searches in the entire XML content. Problems started when you checked the "XML Search Options" which divides the XML document in intervals (element names, text content, attribute names, attribute values) and searches only in those intervals for the text to find.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply