0

I use XML template files in a Java project using Netbeans 8.2.

For the template file i use the .mustache.xml file extension, so the syntax is highlighted.

First line of the XML template file is:

<?xml version="1.0" encoding="{{_output.encoding}}"?>

Netbeans refuses to save the file, because {{_output.encoding}} is not a valid encoding :( If i save the file as UTF-8, the template is changed!

Is there any setting to disable this check?

rmuller
  • 12,062
  • 4
  • 64
  • 92

1 Answers1

0

I don't see how to prevent your XML file's encoding value being validated in NetBeans when saving the file.

You could easily provide your own DTD or XSD file for validation within the template file, but even then I don't think it is possible to specify in that file that the invalid encoding value in the XML declaration (the first line in your file) should be ignored.

It's worth noting that NetBeans refuses to save any file with an XML declaration with an invalid encoding on it first line, regardless of the file's extension. For example, it won't even save this file with an arbitrary extension named newXMLDocument1.xml2:

enter image description here

Of course the file can be saved if the XML declaration with the invalid encoding is not the first line in the file. For example:

<!-- Any comment -->
<?xml version="1.0" encoding="zzzz" ?>
<arg>
</arg>

But that doesn't really solve anything. It's just changing one form of invalid XML for another.

skomisa
  • 16,436
  • 7
  • 61
  • 102
  • Thanks, that confirms my presumption. It does not solve my problem but accepted because this answer is probably right. – rmuller Oct 25 '17 at 05:06
  • @rmuller Yes, it's both frustrating and surprising that your simple requirement cannot be achieved. Also, I just saw another SO post which explains why validation of the encoding value is not possible using an xsd file: https://stackoverflow.com/questions/4412343/can-xsd-schema-validate-encoding-e-g-utf-8-possible?rq=1 – skomisa Oct 25 '17 at 05:43