Searching for Text in Reused Components in Current Dita Map Hierarchy

jmorales
Posts: 40
Joined: Tue Oct 30, 2018 9:47 pm

Searching for Text in Reused Components in Current Dita Map Hierarchy

Post by jmorales » Wed Oct 02, 2019 2:37 am

Hi, I have some text that needs to appear in several topics in my book, so I put it in a separate component and did a conref to that component from each of the affected topics. Then I did a Find/Replace in Files, with the find target being some text in the reused component, and set the scope of my search to Current DITA Map Hierarchy. The search didn't find anything, which sort of makes sense because the reused text is no longer directly present in my topics. On the other hand, that means that it's going to be difficult to find the location of that reused text in my topics in this book in the future. I would have to remember the name of the component that is being reused, and do a find on the name of the component.

To find things easily in my book, it would help a lot if a search of Current DITA Map Hierarchy would also return any topics that contain the find target as part of an embedded component. Or,if you feel that you cannot change the meaning of "Current DITA Map Hierarchy", then perhaps you could add another scope to the list called "Current DITA Map Hierarchy and Embedded Components." I feel that this would be a tremendously helpful feature even if it makes the search run slower.

On the other hand, is there already some way to get the effect that I want? Perhaps I just haven't stumbled across it.

Thanks!

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

Re: Searching for Text in Reused Components in Current Dita Map Hierarchy

Post by Radu » Wed Oct 02, 2019 8:21 am

Hi,

Our Find/Replace in Files action searches only in the current content of the XML document, it does not expand content references to search also inside them.
The best practice when you have topics containing only reusable content is to also refer to them in the DITA Map, setting the "processing-role='resource-only'" attribute on the topicref to indicate that the topic is not published but it contributes reusable components for other topics.
Once that topic will be referenced in the DITA Map the "Find/Replace In Files" will start finding the content inside it.
You could for example have a special "reusables.ditamap" which refers to all topics with reusable components and is referenced in the main DITA Map:

https://github.com/oxygenxml/dita-proje ... -practices

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

jmorales
Posts: 40
Joined: Tue Oct 30, 2018 9:47 pm

Re: Searching for Text in Reused Components in Current Dita Map Hierarchy

Post by jmorales » Thu Oct 03, 2019 12:35 am

Thanks Radu. I can see that including the reusable content as a "resource-only" entry in the ditamap would help. Where it gets a little complicated is if you have a number of components that are reused in topics in one book, and maybe some of those components are also reused in topics in other books. If you group components together into a collection, and add it to your ditamap as a "resource-only" entry, but your current book uses only some of those components, then your Find may locate text in components that are not really used in the current book. It seems like the only sure way to prevent this would be to always store each component in a separate file, right? Then you could add "resource-only" entries in your ditamap for only the components you are really using.

I can see this as a viable workaround, but going forward, it would certainly be more convenient if Find/Replace in Files could expand content references to also search inside them. The Find results could list all the topics that contain the target text, either directly or within a nested component. Then you could double-click each topic in the Find results to easily view each found item in the context of the topic where it is used. Just something for you to consider. Author Mode already gives a combined view of a topic and the text from any components it references, so clearly you already know how to do this sort of thing.

Thanks for your consideration and for your suggestion!

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

Re: Searching for Text in Reused Components in Current Dita Map Hierarchy

Post by Radu » Thu Oct 03, 2019 8:10 am

Hi,

Thanks for the improvement request, I added an internal issue for it.

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

kirkilj
Posts: 79
Joined: Fri May 14, 2010 12:14 am

Re: Searching for Text in Reused Components in Current Dita Map Hierarchy

Post by kirkilj » Thu Oct 03, 2019 8:43 pm

+1 on this enhancement request.

In the mean time, would it be sufficient to invoke the "Open Map in Editor with resolved topics" in Author mode and then invoke Find All on the combined content? It's not ideal for replacements; however, since you'd have to invoke the "Edit Reference" function to get read/write access and make changes in the referenced file. This might be sufficient with a small docset, but it would probably be untenable for any map consisting of hundreds of topics or more.

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

Re: Searching for Text in Reused Components in Current Dita Map Hierarchy

Post by Radu » Fri Oct 04, 2019 8:45 am

Hi John,

Thanks for providing a possible workaround, indeed it's a decent solution on small projects.
I added your vote on the issue I opened for this request.

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

jmorales
Posts: 40
Joined: Tue Oct 30, 2018 9:47 pm

Re: Searching for Text in Reused Components in Current Dita Map Hierarchy

Post by jmorales » Wed Oct 09, 2019 7:36 pm

Thanks kirkilj for the workaround suggestion, I will experiment with that approach.

Post Reply