aboutsummaryrefslogtreecommitdiff
path: root/projects/xerces-c/xmlProtoConverter.cpp
blob: b2caf67a28b7f884e9f111864c5b97c182261e51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
/*
 * Copyright (C) 2019 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "xmlProtoConverter.h"

#include <algorithm>

using namespace std;
using namespace xmlProtoFuzzer;

string ProtoConverter::removeNonAscii(string const& _utf8)
{
	string asciiStr{_utf8};
	asciiStr.erase(remove_if(asciiStr.begin(), asciiStr.end(), [=](char c) -> bool {
                        return !(std::isalpha(c) || std::isdigit(c));
                }), asciiStr.end());
	return asciiStr.empty() ? "fuzz" : asciiStr;
}


void ProtoConverter::visit(Misc const& _x)
{
	switch (_x.misc_oneof_case())
	{
	case Misc::kComment:
		m_output << "<!--" << _x.comment() << "-->\n";
		break;
	case Misc::kInst:
		visit(_x.inst());
		break;
	case Misc::MISC_ONEOF_NOT_SET:
		break;
	}
}

void ProtoConverter::visit(Prolog const& _x)
{
	visit(_x.decl());
	visit(_x.doctype());
	for (auto const& misc: _x.misc())
		visit(misc);
}

void ProtoConverter::visit(KeyValue const& _x)
{
	switch (_x.type())
	{
	case KeyValue::ATTRIBUTES:
		m_output << "xml:attributes=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::BASE:
		m_output << "xml:base=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::CATALOG:
		m_output << "xml:catalog=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::ID:
		m_output << "xml:id=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::LANG:
		m_output << "xml:lang=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::LINK:
		m_output << "xml:link=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::SPACE:
		m_output << "xml:space=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::SPECIAL:
		m_output << "xml:special=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::TEST:
		m_output << "xml:test=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue::FUZZ:
		if (_x.ByteSizeLong() % 2)
			m_output << "xmlns:" << removeNonAscii(_x.key()) << "=\"" << removeNonAscii(_x.value()) << "\" ";
		else
			m_output << removeNonAscii(_x.key()) << "=\"" << removeNonAscii(_x.value()) << "\" ";
		break;
	case KeyValue_XmlNamespace_KeyValue_XmlNamespace_INT_MIN_SENTINEL_DO_NOT_USE_:
	case KeyValue_XmlNamespace_KeyValue_XmlNamespace_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
}

void ProtoConverter::visit(ProcessingInstruction const& _x)
{
	m_output << "<?" << removeNonAscii(_x.name()) << " ";
	for (auto const& prop: _x.kv())
		visit(prop);
	m_output << "?>\n";
}

void ProtoConverter::visit(Content const& _x)
{
	switch (_x.content_oneof_case())
	{
	case Content::kStr:
		m_output << _x.str() << "\n";
		break;
	case Content::kE:
		visit(_x.e());
		m_output << "\n";
		break;
	case Content::kC:
		visit(_x.c());
		m_output << "\n";
		break;
	case Content::CONTENT_ONEOF_NOT_SET:
		break;
	}
}

void ProtoConverter::visit(ElementDecl const& _x)
{
	m_output << "<!ELEMENT " << _x.name() << " ";
	switch (_x.spec())
	{
	case ElementDecl::EMPTY:
		m_output << "EMPTY>";
		break;
	case ElementDecl::ANY:
		m_output << "ANY>";
		break;
	case ElementDecl::FUZZ:
		m_output << "FUZZ>";
		break;
	case ElementDecl::MIXED:
		m_output << "(#PCDATA";
		for (auto const& pcdata: _x.cdata())
			m_output << "|" << pcdata;
		m_output << ")";
		if (_x.cdata_size() > 0)
			m_output << "*";
		m_output << ">";
		break;
	case ElementDecl::CHILDREN:
	{
		m_output << "(";
		string delim = "";
		for (auto const& str: _x.cdata()) {
			m_output << delim << removeNonAscii(str);
			delim = ", ";
		}
		m_output << ")>";
		break;
	}
	case ElementDecl_ContentSpec_ElementDecl_ContentSpec_INT_MIN_SENTINEL_DO_NOT_USE_:
	case ElementDecl_ContentSpec_ElementDecl_ContentSpec_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
}

void ProtoConverter::visit(AttValue const& _x)
{
	m_output << "\"";
	string prefix;
	switch (_x.type())
	{
	case AttValue::ENTITY:
		prefix = "&";
		break;
	case AttValue::CHAR:
		if (_x.ByteSizeLong() % 2)
			prefix = "&#";
		else
			// TODO: Value that follows this must be a
			// sequence of hex digits.
			prefix = "&#x";
		break;
	case AttValue::FUZZ:
		prefix = "fuzz";
		break;
	case AttValue_Type_AttValue_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case AttValue_Type_AttValue_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
	for (auto const& name: _x.value())
		m_output << prefix << removeNonAscii(name) << ";";
	m_output << "\"";
}

void ProtoConverter::visit(DefaultDecl const& _x)
{
	switch (_x.type())
	{
	case DefaultDecl::REQUIRED:
		m_output << "#REQUIRED";
		break;
	case DefaultDecl::IMPLIED:
		m_output << "#IMPLIED";
		break;
	case DefaultDecl::FIXED:
		m_output << "#FIXED ";
		visit(_x.att());
		break;
	case DefaultDecl::FUZZ:
		m_output << "#FUZZ";
		break;
	case DefaultDecl_Type_DefaultDecl_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case DefaultDecl_Type_DefaultDecl_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
}

void ProtoConverter::visit(AttDef const& _x)
{
	m_output << " " << removeNonAscii(_x.name()) << " ";
	switch (_x.type())
	{
	case AttDef::CDATA:
		m_output << "CDATA ";
		break;
	case AttDef::ID:
		m_output << "ID ";
		break;
	case AttDef::IDREF:
		m_output << "IDREF ";
		break;
	case AttDef::IDREFS:
		m_output << "IDREFS ";
		break;
	case AttDef::ENTITY:
		m_output << "ENTITY ";
		break;
	case AttDef::ENTITIES:
		m_output << "ENTITIES ";
		break;
	case AttDef::NMTOKEN:
		m_output << "NMTOKEN ";
		break;
	case AttDef::NMTOKENS:
		m_output << "NMTOKENS ";
		break;
	case AttDef::FUZZ:
		m_output << "FUZZ ";
		break;
	case AttDef_Type_AttDef_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case AttDef_Type_AttDef_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
	visit(_x.def());
}

void ProtoConverter::visit(AttListDecl const& _x)
{
	m_output << "<!ATTLIST " << removeNonAscii(_x.name());
	for (auto const& att: _x.attdefs())
		visit(att);
	m_output << ">";
}

void ProtoConverter::visit(NotationDecl const& _x)
{
	m_output << "<!NOTATION " << removeNonAscii(_x.name()) << " ";
	switch (_x.notation_oneof_case())
	{
	case NotationDecl::kExt:
		visit(_x.ext());
		break;
	case NotationDecl::kPub:
		m_output << "PUBLIC " << _x.pub();
		break;
	case NotationDecl::kFuzz:
		m_output << "FUZZ " << _x.fuzz();
		break;
	case NotationDecl::NOTATION_ONEOF_NOT_SET:
		break;
	}
	m_output << ">";
}

void ProtoConverter::visit(NDataDecl const& _x)
{
	m_output << " NDATA " << _x.name();
}

void ProtoConverter::visit(EntityDef const& _x)
{
	switch (_x.entity_oneof_case())
	{
	case EntityDef::kExt:
		visit(_x.ext());
		if (_x.ByteSizeLong() % 2)
			visit(_x.ndata());
		break;
	case EntityDef::kVal:
		visit(_x.val());
		break;
	case EntityDef::ENTITY_ONEOF_NOT_SET:
		break;
	}
}

void ProtoConverter::visit(PEDef const& _x)
{
	switch (_x.pedef_oneof_case())
	{
	case PEDef::kVal:
		visit(_x.val());
		break;
	case PEDef::kId:
		visit(_x.id());
		break;
	case PEDef::PEDEF_ONEOF_NOT_SET:
		break;
	}
}

void ProtoConverter::visit(EntityValue const& _x)
{
	m_output << "\"";
	string prefix;
	switch (_x.type())
	{
	case EntityValue::ENTITY:
		prefix = "&";
		break;
	case EntityValue::CHAR:
		if (_x.ByteSizeLong() % 2)
			prefix = "&#";
		else
			prefix = "&#x";
		break;
	case EntityValue::PEREF:
		prefix = "%";
		break;
	case EntityValue::FUZZ:
		prefix = "fuzz";
		break;
	case EntityValue_Type_EntityValue_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case EntityValue_Type_EntityValue_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
	for (auto const& ref: _x.name())
		m_output << prefix << ref << ";";
	m_output << "\"";
}

void ProtoConverter::visit(EntityDecl const& _x)
{
	m_output << "<!ENTITY ";
	switch (_x.type())
	{
	case EntityDecl::GEDECL:
		m_output << _x.name() << " ";
		visit(_x.ent());
		break;
	case EntityDecl::PEDECL:
		m_output << "% " << _x.name() << " ";
		visit(_x.pedef());
		break;
	case EntityDecl_Type_EntityDecl_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case EntityDecl_Type_EntityDecl_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
	m_output << ">";
}

void ProtoConverter::visit(ConditionalSect const& _x)
{
	switch (_x.type())
	{
	case ConditionalSect::INCLUDE:
		m_output << "<![ INCLUDE [";
		visit(_x.ext());
		m_output << "]]>";
		break;
	case ConditionalSect::IGNORE:
		m_output << "<![ IGNORE [";
		for (auto const& str: _x.ignores())
			m_output << "<![" << removeNonAscii(str) << "]]>";
		m_output << "]]>";
		break;
	case ConditionalSect::FUZZ:
		m_output << "<![ FUZZ [";
		visit(_x.ext());
		m_output << "]]>";
		break;
	case ConditionalSect_Type_ConditionalSect_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case ConditionalSect_Type_ConditionalSect_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
}


void ProtoConverter::visit(OneExtSubsetDecl const& _x)
{
	switch (_x.extsubset_oneof_case())
	{
	case OneExtSubsetDecl::kM:
		visit(_x.m());
		break;
	case OneExtSubsetDecl::kC:
		visit(_x.c());
		break;
	case OneExtSubsetDecl::EXTSUBSET_ONEOF_NOT_SET:
		break;
	}
}


void ProtoConverter::visit(ExtSubsetDecl const& _x)
{
	for (auto const& decl: _x.decls())
		visit(decl);
}

void ProtoConverter::visit(CData const& _x)
{
	m_output << "<![CDATA[" << removeNonAscii(_x.data()) << "]]>";
}

void ProtoConverter::visit(MarkupDecl const& _x)
{
	switch (_x.markup_oneof_case())
	{
	case MarkupDecl::kE:
		visit(_x.e());
		break;
	case MarkupDecl::kA:
		visit(_x.a());
		break;
	case MarkupDecl::kN:
		visit(_x.n());
		break;
	case MarkupDecl::kM:
		visit(_x.m());
		break;
	case MarkupDecl::kEntity:
		visit(_x.entity());
		break;
	case MarkupDecl::kExt:
		visit(_x.ext());
		break;
	case MarkupDecl::MARKUP_ONEOF_NOT_SET:
		break;
	}
}

/// Returns predefined element from an Element_Id enum
/// @param _x is an enum that holds the desired type of predefined value
/// @param _prop is a string that holds the value of the desired type
/// @return string holding the predefined value of the form
/// name attribute=\"value\"
string ProtoConverter::getPredefined(Element_Id _x, string const& _prop)
{
	string output{};
	switch (_x)
	{
	case Element::XIINCLUDE:
	case Element::XIFALLBACK:
	case Element::XIHREF:
		output = "xi:include href=\"fuzz.xml\"";
	case Element::XIPARSE:
		output = "xi:include parse=\"xml\"";
	case Element::XIXPOINTER:
		output = "xi:include xpointer=\"" + removeNonAscii(_prop) + "\"";
	case Element::XIENCODING:
		output = "xi:include encoding=\"" + removeNonAscii(_prop) + "\"";
	case Element::XIACCEPT:
		output = "xi:include accept=\"" + removeNonAscii(_prop) + "\"";
	case Element::XIACCEPTLANG:
		output = "xi:include accept-language=\"" + removeNonAscii(_prop) + "\"";
	case Element_Id_Element_Id_INT_MIN_SENTINEL_DO_NOT_USE_:
	case Element_Id_Element_Id_INT_MAX_SENTINEL_DO_NOT_USE_:
		output = "xi:fuzz xifuzz=\"fuzz\"";
	}
	return output;
}

/// Returns uri string for a given Element_Id type
string ProtoConverter::getUri(Element_Id _x)
{
	switch (_x)
	{
	case Element::XIINCLUDE:
	case Element::XIFALLBACK:
	case Element::XIHREF:
	case Element::XIPARSE:
	case Element::XIXPOINTER:
	case Element::XIENCODING:
	case Element::XIACCEPT:
	case Element::XIACCEPTLANG:
	case Element_Id_Element_Id_INT_MIN_SENTINEL_DO_NOT_USE_:
	case Element_Id_Element_Id_INT_MAX_SENTINEL_DO_NOT_USE_:
		return s_XInclude;
	}
}

void ProtoConverter::visit(Element const& _x)
{
	// Predefined child node
	string child = {};
	// Predefined uri for child node
	string pUri = {};
	// Element name
	string name = removeNonAscii(_x.name());

	switch (_x.type())
	{
	case Element::PREDEFINED:
		child = getPredefined(_x.id(), _x.childprop());
		pUri = getUri(_x.id());
		break;
	case Element::FUZZ:
	case Element_Type_Element_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case Element_Type_Element_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}

	// <name k1=v1 k2=v2 k3=v3>
	// <content>
	// </name>

	// Start name tag: Must be Ascii?
	m_output << "<" << name << " ";

	// Add uri to name tag
	if (!pUri.empty())
		m_output << pUri << " ";
	for (auto const& prop: _x.kv())
		visit(prop);
	m_output << ">\n";

	// Add attribute
	if (!child.empty())
		m_output << "<" << child << "/>\n";

	// Add content
	visit(_x.content());

	// Close name tag
	m_output << "</" << name << ">\n";
}

void ProtoConverter::visit(ExternalId const& _x)
{
	switch (_x.type())
	{
	case ExternalId::SYSTEM:
		m_output << "SYSTEM " << "\"" << removeNonAscii(_x.system()) << "\"";
		break;
	case ExternalId::PUBLIC:
		m_output << "PUBLIC " << "\"" << removeNonAscii(_x.pub()) << "\""
			<< " " << "\"" << removeNonAscii(_x.system()) << "\"";
		break;
	case ExternalId::FUZZ:
		m_output << "FUZZ " << "\"" << removeNonAscii(_x.pub()) << "\"";
		break;
	case ExternalId_Type_ExternalId_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case ExternalId_Type_ExternalId_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
}

void ProtoConverter::visit(DocTypeDecl const& _x)
{
	m_output << "<!DOCTYPE " << removeNonAscii(_x.name()) << " ";
	visit(_x.ext());
	m_output << "[";
	for (auto const& m: _x.mdecl())
		visit(m);
	m_output << "]";
	m_output << ">\n";
}

void ProtoConverter::visit(VersionNum const& _x)
{
	switch (_x.type())
	{
	case VersionNum::STANDARD:
		m_output << "\"1.0\"";
		break;
	case VersionNum::FUZZ:
	case VersionNum_Type_VersionNum_Type_INT_MIN_SENTINEL_DO_NOT_USE_:
	case VersionNum_Type_VersionNum_Type_INT_MAX_SENTINEL_DO_NOT_USE_:
		m_output << "\"" << _x.major() << "." << _x.minor() << "\"";
		break;
	}
}

void ProtoConverter::visit(Encodings const& _x)
{
	m_output << " encoding=\"";
	switch (_x.name())
	{
	case Encodings::BIG5:
		m_output << "BIG5";
		break;
	case Encodings::EUCJP:
		m_output << "EUC-JP";
		break;
	case Encodings::EUCKR:
		m_output << "EUC-KR";
		break;
	case Encodings::GB18030:
		m_output << "GB18030";
		break;
	case Encodings::ISO2022JP:
		m_output << "ISO-2022-JP";
		break;
	case Encodings::ISO2022KR:
		m_output << "ISO-2022-KR";
		break;
	case Encodings::ISO88591:
		m_output << "ISO-8859-1";
		break;
	case Encodings::ISO88592:
		m_output << "ISO-8859-2";
		break;
	case Encodings::ISO88593:
		m_output << "ISO-8859-3";
		break;
	case Encodings::ISO88594:
		m_output << "ISO-8859-4";
		break;
	case Encodings::ISO88595:
		m_output << "ISO-8859-5";
		break;
	case Encodings::ISO88596:
		m_output << "ISO-8859-6";
		break;
	case Encodings::ISO88597:
		m_output << "ISO-8859-7";
		break;
	case Encodings::ISO88598:
		m_output << "ISO-8859-8";
		break;
	case Encodings::ISO88599:
		m_output << "ISO-8859-9";
		break;
	case Encodings::SHIFTJIS:
		m_output << "SHIFT_JIS";
		break;
	case Encodings::TIS620:
		m_output << "TIS-620";
		break;
	case Encodings::USASCII:
		m_output << "US-ASCII";
		break;
	case Encodings::UTF8:
		m_output << "UTF-8";
		break;
	case Encodings::UTF16:
		m_output << "UTF-16";
		break;
	case Encodings::UTF16BE:
		m_output << "UTF-16BE";
		break;
	case Encodings::UTF16LE:
		m_output << "UTF-16LE";
		break;
	case Encodings::WINDOWS31J:
		m_output << "WINDOWS-31J";
		break;
	case Encodings::WINDOWS1255:
		m_output << "WINDOWS-1255";
		break;
	case Encodings::WINDOWS1256:
		m_output << "WINDOWS-1256";
		break;
	case Encodings::FUZZ:
		m_output << removeNonAscii(_x.fuzz());
		break;
	case Encodings_Enc_Encodings_Enc_INT_MIN_SENTINEL_DO_NOT_USE_:
	case Encodings_Enc_Encodings_Enc_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
	m_output << "\"";
}

void ProtoConverter::visit(XmlDeclaration const& _x)
{
	m_output << R"(<?xml version=)";
	visit(_x.ver());
	visit(_x.enc());
	switch (_x.standalone())
	{
	case XmlDeclaration::YES:
		m_output << " standalone=\'yes\'";
		break;
	case XmlDeclaration::NO:
		m_output << " standalone=\'no\'";
		break;
	case XmlDeclaration_Standalone_XmlDeclaration_Standalone_INT_MIN_SENTINEL_DO_NOT_USE_:
	case XmlDeclaration_Standalone_XmlDeclaration_Standalone_INT_MAX_SENTINEL_DO_NOT_USE_:
		break;
	}
	m_output << "?>\n";
}

void ProtoConverter::visit(XmlDocument const& _x)
{
	visit(_x.p());
	for (auto const& element: _x.e())
		visit(element);
}

string ProtoConverter::protoToString(XmlDocument const& _x)
{
	visit(_x);
	return m_output.str();
}