@@ -284,13 +284,15 @@ protected final String expect(String expect) {
284
284
public abstract String outputElementContentString (Format format , Element element );
285
285
286
286
protected static final Format fraw = Format .getRawFormat ();
287
+ protected static final Format frawfp = Format .getPrettyFormat ().setTextMode (TextMode .PRESERVE );
287
288
protected static final Format fcompact = Format .getCompactFormat ();
288
289
protected static final Format fpretty = Format .getPrettyFormat ();
289
290
protected static final Format ftso = Format .getPrettyFormat ();
290
291
protected static final Format ftfw = Format .getPrettyFormat ();
291
292
292
293
static {
293
294
fraw .setLineSeparator ("\n " );
295
+ frawfp .setLineSeparator ("\n " );
294
296
fcompact .setLineSeparator ("\n " );
295
297
fpretty .setLineSeparator ("\n " );
296
298
ftso .setLineSeparator ("\n " );
@@ -304,6 +306,7 @@ protected final String expect(String expect) {
304
306
public void testTextEmpty () {
305
307
Text content = new Text ("" );
306
308
assertEquals ("" , outputString (fraw , content ));
309
+ assertEquals ("" , outputString (frawfp , content ));
307
310
assertEquals ("" , outputString (fcompact , content ));
308
311
assertEquals ("" , outputString (fpretty , content ));
309
312
assertEquals ("" , outputString (ftso , content ));
@@ -315,6 +318,8 @@ public void testTextWhitespace() {
315
318
Text content = new Text (" \r \n \t " );
316
319
assertEquals (expect (" \r \n \t " ),
317
320
outputString (fraw , content ));
321
+ assertEquals (expect (" \r \n \t " ),
322
+ outputString (frawfp , content ));
318
323
assertEquals ("" ,
319
324
outputString (fcompact , content ));
320
325
assertEquals ("" ,
@@ -330,6 +335,8 @@ public void testTextWithText() {
330
335
Text content = new Text (" \r & \n \t " );
331
336
assertEquals (expect (" \r & \n \t " ),
332
337
outputString (fraw , content ));
338
+ assertEquals (expect (" \r & \n \t " ),
339
+ outputString (frawfp , content ));
333
340
assertEquals (expect ("&" ),
334
341
outputString (fcompact , content ));
335
342
assertEquals (expect ("&" ),
@@ -345,6 +352,8 @@ public void testCDATAEmpty() {
345
352
CDATA content = new CDATA ("" );
346
353
assertEquals ("<![CDATA[]]>" ,
347
354
outputString (fraw , content ));
355
+ assertEquals ("<![CDATA[]]>" ,
356
+ outputString (frawfp , content ));
348
357
assertEquals ("" ,
349
358
outputString (fcompact , content ));
350
359
assertEquals ("" ,
@@ -360,6 +369,8 @@ public void testCDATAWhitespace() {
360
369
CDATA content = new CDATA (" \r \n \t " );
361
370
assertEquals ("<![CDATA[ \r \n \t ]]>" ,
362
371
outputString (fraw , content ));
372
+ assertEquals ("<![CDATA[ \r \n \t ]]>" ,
373
+ outputString (frawfp , content ));
363
374
assertEquals ("" ,
364
375
outputString (fcompact , content ));
365
376
assertEquals ("" ,
@@ -375,6 +386,8 @@ public void testCDATAWithText() {
375
386
CDATA content = new CDATA (" \r & \n \t " );
376
387
assertEquals ("<![CDATA[ \r & \n \t ]]>" ,
377
388
outputString (fraw , content ));
389
+ assertEquals ("<![CDATA[ \r & \n \t ]]>" ,
390
+ outputString (frawfp , content ));
378
391
assertEquals ("<![CDATA[&]]>" ,
379
392
outputString (fcompact , content ));
380
393
assertEquals ("<![CDATA[&]]>" ,
@@ -390,6 +403,8 @@ public void testEntityRef() {
390
403
EntityRef content = new EntityRef ("ref" );
391
404
assertEquals ("&ref;" ,
392
405
outputString (fraw , content ));
406
+ assertEquals ("&ref;" ,
407
+ outputString (frawfp , content ));
393
408
assertEquals ("&ref;" ,
394
409
outputString (fcompact , content ));
395
410
assertEquals ("&ref;" ,
@@ -405,6 +420,8 @@ public void testProcessingInstructionTargetOnly() {
405
420
ProcessingInstruction content = new ProcessingInstruction ("target" );
406
421
assertEquals (expect ("<?target?>" ),
407
422
outputString (fraw , content ));
423
+ assertEquals (expect ("<?target?>" ),
424
+ outputString (frawfp , content ));
408
425
assertEquals (expect ("<?target?>" ),
409
426
outputString (fcompact , content ));
410
427
assertEquals (expect ("<?target?>" ),
@@ -419,6 +436,8 @@ public void testProcessingInstructionTargetWithData() {
419
436
new ProcessingInstruction ("target" , "data" );
420
437
assertEquals ("<?target data?>" ,
421
438
outputString (fraw , content ));
439
+ assertEquals ("<?target data?>" ,
440
+ outputString (frawfp , content ));
422
441
assertEquals ("<?target data?>" ,
423
442
outputString (fcompact , content ));
424
443
assertEquals ("<?target data?>" ,
@@ -434,6 +453,8 @@ public void testComment() {
434
453
Comment content = new Comment ("comment" );
435
454
assertEquals ("<!--comment-->" ,
436
455
outputString (fraw , content ));
456
+ assertEquals ("<!--comment-->" ,
457
+ outputString (frawfp , content ));
437
458
assertEquals ("<!--comment-->" ,
438
459
outputString (fcompact , content ));
439
460
assertEquals ("<!--comment-->" ,
@@ -450,6 +471,8 @@ public void testDocTypeSimple() {
450
471
DocType content = new DocType ("root" );
451
472
assertEquals ("<!DOCTYPE root>" ,
452
473
outputString (fraw , content ));
474
+ assertEquals ("<!DOCTYPE root>" ,
475
+ outputString (frawfp , content ));
453
476
assertEquals ("<!DOCTYPE root>" ,
454
477
outputString (fcompact , content ));
455
478
assertEquals ("<!DOCTYPE root>" ,
@@ -466,6 +489,8 @@ public void testDocTypeSimpleISS() {
466
489
content .setInternalSubset ("<!ENTITY name \" value\" >" );
467
490
assertEquals ("<!DOCTYPE root [\n <!ENTITY name \" value\" >]>" ,
468
491
outputString (fraw , content ));
492
+ assertEquals ("<!DOCTYPE root [\n <!ENTITY name \" value\" >]>" ,
493
+ outputString (frawfp , content ));
469
494
assertEquals ("<!DOCTYPE root [\n <!ENTITY name \" value\" >]>" ,
470
495
outputString (fcompact , content ));
471
496
assertEquals ("<!DOCTYPE root [\n <!ENTITY name \" value\" >]>" ,
@@ -481,6 +506,8 @@ public void testDocTypeSystemID() {
481
506
DocType content = new DocType ("root" , "sysid" );
482
507
assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" >" ,
483
508
outputString (fraw , content ));
509
+ assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" >" ,
510
+ outputString (frawfp , content ));
484
511
assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" >" ,
485
512
outputString (fcompact , content ));
486
513
assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" >" ,
@@ -497,6 +524,8 @@ public void testDocTypeSystemIDISS() {
497
524
content .setInternalSubset ("internal" );
498
525
assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" [\n internal]>" ,
499
526
outputString (fraw , content ));
527
+ assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" [\n internal]>" ,
528
+ outputString (frawfp , content ));
500
529
assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" [\n internal]>" ,
501
530
outputString (fcompact , content ));
502
531
assertEquals ("<!DOCTYPE root SYSTEM \" sysid\" [\n internal]>" ,
@@ -512,6 +541,8 @@ public void testDocTypePublicSystemID() {
512
541
DocType content = new DocType ("root" , "pubid" , "sysid" );
513
542
assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" >" ,
514
543
outputString (fraw , content ));
544
+ assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" >" ,
545
+ outputString (frawfp , content ));
515
546
assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" >" ,
516
547
outputString (fcompact , content ));
517
548
assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" >" ,
@@ -528,6 +559,8 @@ public void testDocTypePublicSystemIDISS() {
528
559
content .setInternalSubset ("internal" );
529
560
assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" [\n internal]>" ,
530
561
outputString (fraw , content ));
562
+ assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" [\n internal]>" ,
563
+ outputString (frawfp , content ));
531
564
assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" [\n internal]>" ,
532
565
outputString (fcompact , content ));
533
566
assertEquals ("<!DOCTYPE root PUBLIC \" pubid\" \" sysid\" [\n internal]>" ,
@@ -551,6 +584,8 @@ public void testMultiWhiteText() {
551
584
root .addContent (new Text (" " ));
552
585
assertEquals (expect ("<root><![CDATA[ ]]> \n \n \t </root>" ),
553
586
outputString (fraw , root ));
587
+ assertEquals (expect ("<root><![CDATA[ ]]> \n \n \t </root>" ),
588
+ outputString (frawfp , root ));
554
589
assertEquals (expect ("<root/>" ),
555
590
outputString (fcompact , root ));
556
591
assertEquals (expect ("<root/>" ),
@@ -574,6 +609,8 @@ public void testMultiText() {
574
609
root .addContent (new Text (" " ));
575
610
assertEquals (expect ("<root><![CDATA[ ]]> X \n \n \t </root>" ),
576
611
outputString (fraw , root ));
612
+ assertEquals (expect ("<root><![CDATA[ ]]> X \n \n \t </root>" ),
613
+ outputString (frawfp , root ));
577
614
assertEquals (expect ("<root>X</root>" ),
578
615
outputString (fcompact , root ));
579
616
assertEquals (expect ("<root>X</root>" ),
@@ -589,6 +626,8 @@ public void testDocumentSimple() {
589
626
Document content = new Document ();
590
627
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ,
591
628
outputString (fraw , content ));
629
+ assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ,
630
+ outputString (frawfp , content ));
592
631
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ,
593
632
outputString (fcompact , content ));
594
633
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " ,
@@ -605,6 +644,8 @@ public void testDocumentDocType() {
605
644
content .setDocType (new DocType ("root" ));
606
645
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!DOCTYPE root>\n " ,
607
646
outputString (fraw , content ));
647
+ assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!DOCTYPE root>\n " ,
648
+ outputString (frawfp , content ));
608
649
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!DOCTYPE root>\n " ,
609
650
outputString (fcompact , content ));
610
651
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!DOCTYPE root>\n " ,
@@ -621,6 +662,8 @@ public void testDocumentComment() {
621
662
content .addContent (new Comment ("comment" ));
622
663
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!--comment-->\n " ,
623
664
outputString (fraw , content ));
665
+ assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!--comment-->\n " ,
666
+ outputString (frawfp , content ));
624
667
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!--comment-->\n " ,
625
668
outputString (fcompact , content ));
626
669
assertEquals ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <!--comment-->\n " ,
@@ -645,6 +688,8 @@ public void testXXX() {
645
688
Text content = new Text ("" );
646
689
assertEquals ("" ,
647
690
outputString (fraw , content ));
691
+ assertEquals ("" ,
692
+ outputString (frawfp , content ));
648
693
assertEquals ("" ,
649
694
outputString (fcompact , content ));
650
695
assertEquals ("" ,
@@ -1337,20 +1382,21 @@ protected void checkOutput(Object content, String methodprefix, Class<?> clazz,
1337
1382
return ;
1338
1383
}
1339
1384
1340
- String [] descn = new String [] {"Raw" , "Compact" , "Pretty" , "PrettySpecifiedOnly" , "TrimFullWhite" };
1385
+ String [] descn = new String [] {"Raw" , "PrettyPreserve" , " Compact" , "Pretty" , "PrettySpecifiedOnly" , "TrimFullWhite" };
1341
1386
Format ftrimfw = Format .getPrettyFormat ();
1342
1387
ftrimfw .setTextMode (TextMode .TRIM_FULL_WHITE );
1343
1388
Format fattspec = Format .getPrettyFormat ();
1344
1389
fattspec .setSpecifiedAttributesOnly (true );
1345
1390
Format [] formats = new Format [] {
1346
1391
getFormat (setup , Format .getRawFormat ()),
1392
+ getFormat (setup , Format .getPrettyFormat ().setTextMode (TextMode .PRESERVE )),
1347
1393
getFormat (setup , Format .getCompactFormat ()),
1348
1394
getFormat (setup , Format .getPrettyFormat ()),
1349
1395
getFormat (setup , fattspec ),
1350
1396
getFormat (setup , ftrimfw )};
1351
- String [] result = new String [] {raw , compact , pretty , tso , trimfw };
1397
+ String [] result = new String [] {raw , raw , compact , pretty , tso , trimfw };
1352
1398
1353
- for (int i = 0 ; i < 5 ; i ++) {
1399
+ for (int i = 0 ; i < result . length ; i ++) {
1354
1400
1355
1401
String mstring ;
1356
1402
try {
0 commit comments