microsoft/XmlNotepad

Disable All Reformatting?

muzicman82 opened this issue · 10 comments

Hello all,

I am trying to use this fantastic program to simply edit some values in an an XML formatted file that is a configuration backup for an AV device. Once I edit it, I can then import it to replace the current configuration.

The trouble I am having is it seems like some of the basic reformatting that happens is causing the import to fail. No details are given. If I use WinMerge to compare, here are some differences:

This:
<?xml version="1.0" encoding="UTF-8"?>
Becomes:
<?xml version="1.0" encoding="utf-8"?>

This:
<item name="ungrouped" sequence="1"/ >
Becomes:
<item name="ungrouped" sequence="1"/>
(The space before the closing > is removed)

I don't know what is and isn't correctly formatted XML, but the point here is the device seems to be rejecting my edits based on things being autoformatted. All I want to do is open it, find text, replace text, and save.

Thanks!

This text is problematic:

<item name="ungrouped" sequence="1"/ >

The space between "/" and ">" is non-compliant according to the XML specification. I would recommend fixing this using a text editor like "Notepad" removing that space before you load the file into XML Notepad. XML Notepad should have failed to load this, unless you have a typo and perhaps the original file contains the space before the slash? This space after foo "" and no space "" is identical as far as the XML specification is concerned. Any application that rejects one of these is non-compliant. XML Notepad currently does not have a way to change this behavior.

Have you tried manually changing the lower case "utf-8" to upper case "UTF-8" and does this make your import work correctly? The XML specification says "XML processors SHOULD match character encoding names in a case-insensitive way".

I'm still trying to get to the bottom of what the device accepts and doesn't accept, but I don't have any control over that device's firmware and I doubt the manufacturer will listen to me in terms of getting their XML files to be compliant. So, that being said, XML Notepad may not be best program to use to edit, or I'll have to do some tweaking after using it. It would be nice for a simple "retain existing formatting" setting where the program only modifies values inside of quotes.

I think I figured things out. The XML Notepad file imports properly with only one change in Notepad++ -- converting it from UTF-8 BOM to UTF-8. None of the other formatting things mattered.

So, is there a way to set this in the program?

Excellent debugging, and yes you can turn on the "No byte order mark on save" option under Formatting Options in the Options dialog:

Image

Perfect! Thanks.

I would love to see the program just format to the same as the source file automatically.

So, I just tried that option, but I get the following error:
Image

Doh, that's bad, working on a fix...

Amazing! Thank you! This now works perfectly with no workarounds.

Awesome, glad to hear it, thanks for the bug replace, please close it if you are happy with this outcome. Cheers.