@@ -247,15 +247,18 @@ public void initGenerator() throws IOException
247
247
}
248
248
_initialized = true ;
249
249
try {
250
+ boolean xmlDeclWritten ;
250
251
if (Feature .WRITE_XML_1_1 .enabledIn (_formatFeatures )) {
251
252
_xmlWriter .writeStartDocument ("UTF-8" , "1.1" );
253
+ xmlDeclWritten = true ;
252
254
} else if (Feature .WRITE_XML_DECLARATION .enabledIn (_formatFeatures )) {
253
255
_xmlWriter .writeStartDocument ("UTF-8" , "1.0" );
256
+ xmlDeclWritten = true ;
254
257
} else {
255
- return ;
258
+ xmlDeclWritten = false ;
256
259
}
257
260
// as per [dataformat-xml#172], try adding indentation
258
- if (_xmlPrettyPrinter != null ) {
261
+ if (xmlDeclWritten && ( _xmlPrettyPrinter != null ) ) {
259
262
// ... but only if it is likely to succeed:
260
263
if (!_stax2Emulation ) {
261
264
_xmlPrettyPrinter .writePrologLinefeed (_xmlWriter );
@@ -487,10 +490,11 @@ public void writeRepeatedFieldName() throws IOException
487
490
/* JsonGenerator method overrides
488
491
/**********************************************************
489
492
*/
490
-
491
- /* Most overrides in this section are just to make methods final,
492
- * to allow better inlining...
493
- */
493
+
494
+ @ Override
495
+ public void writeFieldName (SerializableString name ) throws IOException {
496
+ writeFieldName (name .getValue ());
497
+ }
494
498
495
499
@ Override
496
500
public final void writeFieldName (String name ) throws IOException
@@ -640,12 +644,6 @@ public final void _handleEndObject() throws IOException
640
644
/**********************************************************
641
645
*/
642
646
643
- @ Override
644
- public void writeFieldName (SerializableString name ) throws IOException
645
- {
646
- writeFieldName (name .getValue ());
647
- }
648
-
649
647
@ Override
650
648
public void writeString (String text ) throws IOException
651
649
{
0 commit comments