XPath and XML options not working in Find/Replace in Files

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
sarkipo
Posts: 4
Joined: Wed Mar 04, 2015 4:56 pm

XPath and XML options not working in Find/Replace in Files

Post by sarkipo » Mon Oct 18, 2021 6:40 pm

Hello,

On a fresh installation of Oxygen on a new machine (Windows 10 Pro), trying to use Find/Replace in Files as I've been doing previously,
whenever I specify anything in "Restrict to XPath" or "Enable XML search options" (e.g. "Element contents"), I always get:
Scanned files: 0
Occurrences: 0

When these options are unused, all the files are found ok (but obviously more results than needed).
The same searches on an older machine (Windows 7 Pro 64-bit) with the same version of Oxygen (XML Editor 23.1, build 2021061407) work as expected, with non-zero results.

Would be very grateful for a solution...

adrian
Posts: 2754
Joined: Tue May 17, 2005 4:01 pm

Re: XPath and XML options not working in Find/Replace in Files

Post by adrian » Tue Oct 19, 2021 9:23 am

Hi,

Are you sure this is triggered by "Restrict to XPath" or "Enable XML search options"?
I'm asking because these are just content filters, not file filters. But "Scanned files: 0" means the file filters don't match any files to scan, so please check the Scope and Filters section. "Include files" should be "*.*" to search all files and make sure "[x] Recurse subdirectories" is also checked.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

sarkipo
Posts: 4
Joined: Wed Mar 04, 2015 4:56 pm

Re: XPath and XML options not working in Find/Replace in Files

Post by sarkipo » Tue Oct 19, 2021 12:46 pm

Hi Adrian,

I just found the reason, however I don't quite understand why it behaves this way.

It just did not recognize my files (which have *.exb as extension) as XML.

I'll still note the symptoms here in case someone finds it helpful:
-- When I uncheck those two options, those *.exb files are processed. Otherwise, they are not.
-- If the "Include files" filter is set to *.*, other files which happen to be in the folder (*.html, *.xml etc.) are searched.
-- I renamed one *.exb as *.xml, and it is then searched with the "Enable XML search options" correctly (e.g. element content, attribute values).

-- "Restrict to XPath" also only finds things in *.xml files (including the *.exb renamed as *.xml), but not in *.exb.
-- If the "Include files" filter is set to *.*, it finds things in *.xml and does not say anything at all about *.exb.
-- If the "Include files" filter is set to *.exb, it says "Scanned files: 0", as I said before.

The solution was to add *.exb in Options > Preferences > File types and associate the extension with the XML Editor. Evidently, I did that long ago on the old machine and haven't yet done on the new one.
But why does this setting influence the Find in Files? They all have the <?xml ...?> headers...

adrian
Posts: 2754
Joined: Tue May 17, 2005 4:01 pm

Re: XPath and XML options not working in Find/Replace in Files

Post by adrian » Tue Oct 19, 2021 3:35 pm

Hello,

I've searched the documentation, but this seems to have remained undocumented. I've logged an issue for the documentation team.

Since both XPath filters require that the files to be searched must be well-formed XML files, it was decided that only files that have the XML content type are searched in this case. Oxygen determines the content type from the file types associations. That's why it started working for .exb files immediately after adding the extension to that list.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

sarkipo
Posts: 4
Joined: Wed Mar 04, 2015 4:56 pm

Re: XPath and XML options not working in Find/Replace in Files

Post by sarkipo » Wed Oct 20, 2021 11:01 am

Thanks Adrian,

This should definitely be stated clearly, both in the section for Find&Replace in Files and in the section on File Types Preferences.
By the way, does this mean that I cannot use XML-based search on multiple files if I don't know their extensions? If they have an empty extension? Can I use wildcards in file type associations? (Probably will personally never need that, though).

Greetings,
Alexandre

adrian
Posts: 2754
Joined: Tue May 17, 2005 4:01 pm

Re: XPath and XML options not working in Find/Replace in Files

Post by adrian » Wed Oct 20, 2021 12:39 pm

Hello,
does this mean that I cannot use XML-based search on multiple files if I don't know their extensions? If they have an empty extension?
The XPath and XML search filtering from Find/Replace in Files only work if there is an association in the File Types section for that file extension to an XML-based editor(XML, XSL, XSD). If there is no extension association, or the associated editor is not XML-based, the file is skipped.
You can associate the empty extension with an editor, but by default there is no association.
Can I use wildcards in file type associations?
No, wildcards cannot be used. The associations are for specific file extensions.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Post Reply