Xalan-C++ API Reference 1.12.0
FormatterToXML.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#if !defined(FORMATTERTOXML_HEADER_GUARD_1357924680)
19#define FORMATTERTOXML_HEADER_GUARD_1357924680
20
21
22
23
24// Base include file. Must be first.
26
27
28
30
31
32
34
35
36
39
40
41
42// Base class header file.
44
45
46
47namespace XALAN_CPP_NAMESPACE {
48
49
50
51class Writer;
52class XalanOutputStream;
53
54
55
56/**
57 * FormatterToXML formats SAX-style events into XML.
58 */
60{
61public:
62
63 enum eDummy
64 {
65 eDefaultIndentAmount = 0
66 };
67
68 /**
69 * Constructor for customized encoding and doctype.
70 *
71 * @param writer character output stream to use
72 * @param version version of the output method
73 * @param doIndent true if output is to be indented
74 * @param indent number of spaces to indent at each nesting level
75 * @param encoding character encoding in use by <VAR>writer</VAR>
76 * @param mediaType media type (MIME content type) of the data
77 * @param doctypeSystem system identifier to be used in the document
78 * type declaration
79 * @param doctypePublic public identifier to be used in the document
80 * type declaration
81 * @param xmlDecl true if the XSLT processor should output an XML
82 * declaration
83 * @param standalone true if the XSLT processor should output a
84 * standalone document declaration
85 *
86 * @param format should be used only by derived classes.
87 * @param fBufferData If true, data will be buffered in the formatter
88 */
91 const XalanDOMString& version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
92 bool doIndent = false,
93 int indent = eDefaultIndentAmount,
94 const XalanDOMString& encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
95 const XalanDOMString& mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
96 const XalanDOMString& doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
97 const XalanDOMString& doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
98 bool xmlDecl = true,
99 const XalanDOMString& standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
100 eFormat format = OUTPUT_METHOD_XML,
101 bool fBufferData = true,
102 MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
103
104 static FormatterToXML*
106 MemoryManager& theManager,
107 Writer& writer,
108 const XalanDOMString& version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
109 bool doIndent = false,
110 int indent = eDefaultIndentAmount,
111 const XalanDOMString& encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
112 const XalanDOMString& mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
113 const XalanDOMString& doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
114 const XalanDOMString& doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
115 bool xmlDecl = true,
116 const XalanDOMString& standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
117 eFormat format = OUTPUT_METHOD_XML,
118 bool fBufferData = true);
119
120 virtual
122
123 MemoryManager&
125 {
126 return m_stringBuffer.getMemoryManager();
127 }
128
129 // These methods are inherited from FormatterListener ...
130
131 virtual void
132 setDocumentLocator(const Locator* const locator);
133
134 virtual void
136
137 virtual void
139
140 virtual void
142 const XMLCh* const name,
144
145 virtual void
146 endElement(const XMLCh* const name);
147
148 virtual void
150 const XMLCh* const chars,
151 const size_type length);
152
153 virtual void
155 const XMLCh* const chars,
156 const size_type length);
157
158 virtual void
160
161 virtual void
163 const XMLCh* const chars,
164 const size_type length);
165
166 virtual void
168 const XMLCh* const target,
169 const XMLCh* const data);
170
171
172 virtual void
174
175 virtual void
176 comment(const XMLCh* const data);
177
178 virtual void
180 const XMLCh* const ch,
181 const size_type length);
182
183 virtual Writer*
184 getWriter() const;
185
186 virtual const XalanDOMString&
188
189 virtual const XalanDOMString&
191
192 virtual const XalanDOMString&
193 getEncoding() const;
194
195 virtual const XalanDOMString&
197
198 virtual int
199 getIndent() const;
200
201 const XalanDOMString&
203 {
204 return m_version;
205 }
206
207 const XalanDOMString&
209 {
210 return m_standalone;
211 }
212
213 bool
215 {
216 return m_shouldWriteXMLHeader;
217 }
218
219 void
221 {
222 m_shouldWriteXMLHeader = b;
223 }
224
225 bool
227 {
228 return m_stripCData;
229 }
230
231 void
233 {
234 m_stripCData = b;
235 }
236
237 bool
239 {
240 return m_escapeCData;
241 }
242
243 void
245 {
246 m_escapeCData = b;
247 }
248
249 bool
251 {
252 return m_doIndent;
253 }
254
255 void
256 setDoIndent(bool value)
257 {
258 m_doIndent = value;
259 }
260
261 void
262 setIndent(int value)
263 {
264 m_indent = value;
265 }
266
267
271
272
273protected:
274
275 /**
276 * The writer where the XML will be written.
277 */
279
280 /**
281 * The stream where the XML will be written.
282 */
284
285 /**
286 * Output a line break.
287 */
288 void
290
291 typedef void (FormatterToXML::*AccumCharFunctionType)(XalanDOMChar);
292
293 typedef void (FormatterToXML::*AccumStringFunctionType)(const XalanDOMChar*);
294
295 typedef void (FormatterToXML::*AccumDOMStringFunctionType)(const XalanDOMString&);
296
297 typedef void (FormatterToXML::*AccumArrayFunctionType)(
299 size_type,
300 size_type);
301
302 typedef void (FormatterToXML::*FlushFunctionType)();
303
304 /**
305 * Append a wide character to the buffer.
306 *
307 * Characters that are not representable
308 * in the encoding are not written as
309 * entities.
310 *
311 * @ch the character to append.
312 */
313 void
315 {
316 assert(m_accumNameCharFunction != 0);
317
318 (this->*m_accumNameCharFunction)(ch);
319 }
320
321 /**
322 * Append a wide character to the buffer.
323 *
324 * @ch the character to append.
325 */
326 void
328 {
329 assert(m_accumContentCharFunction != 0);
330
331 (this->*m_accumContentCharFunction)(ch);
332 }
333
334 /**
335 * Append a null-terminated array of wide characters to
336 * the buffer.
337 *
338 * Characters that are not representable
339 * in the encoding are not written as
340 * entities.
341 *
342 * @chars the array to append
343 */
344 void
346 {
347 assert(m_accumNameStringFunction != 0);
348
349 (this->*m_accumNameStringFunction)(chars);
350 }
351
352 /**
353 * Append a null-terminated array of wide characters to
354 * the buffer.
355 *
356 * @chars the array to append
357 */
358 void
360 {
361 assert(m_accumContentStringFunction != 0);
362
363 (this->*m_accumContentStringFunction)(chars);
364 }
365
366 /**
367 * Append an array of wide character to the buffer.
368 *
369 * Characters that are not representable
370 * in the encoding are not written as
371 * entities.
372 *
373 * @chars the array to append
374 * @start the offset into the array to start from
375 * @length the number of characters to append
376 */
377 void
379 const XalanDOMChar chars[],
380 size_type start,
381 size_type length)
382 {
383 assert(m_accumNameArrayFunction != 0);
384
385 (this->*m_accumNameArrayFunction)(chars, start, length);
386 }
387
388 /**
389 * Append an array of wide character to the buffer.
390 *
391 * @chars the array to append
392 * @start the offset into the array to start from
393 * @length the number of characters to append
394 */
395 void
397 const XalanDOMChar chars[],
398 size_type start,
399 size_type length)
400 {
401 assert(m_accumContentArrayFunction != 0);
402
403 (this->*m_accumContentArrayFunction)(chars, start, length);
404 }
405
406 /**
407 * Append a string to the buffer.
408 *
409 * Characters that are not representable
410 * in the encoding are not written as
411 * entities.
412 *
413 * @param str the string to append
414 */
415 void
417 {
418 assert(m_accumNameDOMStringFunction != 0);
419
420 (this->*m_accumNameDOMStringFunction)(str);
421 }
422
423 /**
424 * Append a string to the buffer.
425 *
426 * @param str the string to append
427 */
428 void
430 {
431 assert(m_accumContentDOMStringFunction != 0);
432
433 (this->*m_accumContentDOMStringFunction)(str);
434 }
435
436 /**
437 * Escape and accum a character.
438 */
442 size_type i,
443 const XalanDOMChar chars[],
445 bool escLF);
446
447 /**
448 * Handle one of the default entities, return false if it
449 * is not a default entity.
450 */
451 virtual bool
454 bool escLF);
455
456 /**
457 * Set the attribute characters what will require special mapping.
458 */
459 void
461
462 /**
463 * Set the output characters what will require special mapping.
464 */
465 void
467
468 /**
469 * Flush the char buffer.
470 */
471 void
473
474 /**
475 * Flush the byte buffer.
476 */
477 void
479
480 void
482
483 void
485
486 bool
488
489 bool
491 {
492 return m_doIndent && (!m_ispreserve && !m_isprevtext);
493 }
494
495 /**
496 * Check to see if a parent's ">" has been written, and, if
497 * it has not, write it.
498 */
499 void
501
502 /**
503 * Prints a newline character and <var>n</var> spaces.
504 * @param n Number of spaces to print.
505 */
506 void
507 indent(int n);
508
509 /**
510 * Write normalized characters to the writer.
511 * @param ch the string to write.
512 * @param start the start offset into the string.
513 * @param length the length of the string.
514 * @param isCData true if writing CDATA.
515 */
516 virtual void
518 const XalanDOMChar ch[],
519 size_type start,
520 size_type length,
521 bool isCData);
522
523 /**
524 * Write a number into the buffer as an entity
525 * reference.
526 * @param theNumber the number to write.
527 */
528 void
530
531 /**
532 * Write an attribute string.
533 *
534 * @param theString The string to write.
535 * @param theStringLength The length of the string.
536 */
537 virtual void
539 const XalanDOMChar* theString,
541
542 /**
543 * Write the data for a comment
544 * @param data The comment's data.
545 */
546 virtual void
548
549 /**
550 * Throw an exception when an invalid
551 * surrogate is encountered.
552 * @param ch The first character in the surrogate
553 * @param theManager The MemoryManager instance to use
554 */
555 static void
558 MemoryManager& theManager);
559
560 /**
561 * Throw an exception when an invalid
562 * surrogate is encountered.
563 * @param ch The first character in the surrogate
564 * @param next The next character in the surrogate
565 * @param theManager The MemoryManager instance to use
566 */
567 static void
570 XalanDOMChar next,
571 MemoryManager& theManager);
572
573
574 /**
575 * Throw an exception when an invalid
576 * XML character is encountered.
577 * @param ch The first character in the surrogate
578 * @param next The next character in the surrogate
579 */
580 static void
583 MemoryManager& theManager);
584
585 static bool
587 {
588 return (ch & 0xFC00) == 0xD800 ? true : false;
589 }
590
591 enum eDummyTwo { SPECIALSSIZE = 256};
592
593 /**
594 * The maximum character size before we have to resort
595 * to escaping.
596 */
598
599 XalanDOMChar m_attrCharsMap[SPECIALSSIZE];
600
601 XalanDOMChar m_charsMap[SPECIALSSIZE];
602
603 /**
604 * If true, XML header should be written to output.
605 */
607
608 /**
609 * State flag to tell if preservation of whitespace
610 * is important.
611 */
613
614 /**
615 * Flag to tell if indenting (pretty-printing) is on.
616 */
618
619 /**
620 * Flag to signal that a newline should be added.
621 */
623
624 /**
625 * Flag to tell that we need to add the doctype decl,
626 * which we can't do until the first element is
627 * encountered.
628 */
630
631 /**
632 * State flag that tells if the previous node processed
633 * was text, so we can tell if we should preserve whitespace.
634 */
636
637 /**
638 * If true, cdata sections are simply stripped of their
639 * CDATA brackets, without escaping.
640 */
642
643 /**
644 * Tell if the next text should be raw.
645 */
647
648 /**
649 * Tells if we're in CData section.
650 */
652
653 /**
654 * Flag to quickly tell if the encoding is capable of full
655 * Unicode support.
656 */
658
659 /**
660 * The System ID for the doc type.
661 */
663
664 /**
665 * The public ID for the doc type.
666 */
668
669 /**
670 * The character encoding.
671 */
673
674 /**
675 * Flag to keep track of the indent amount.
676 */
678
679 /**
680 * Amount to indent.
681 */
683
684 /**
685 * Stack to keep track of whether or not we need to
686 * preserve whitespace.
687 */
689
690 // A text buffer. We use it mostly for converting
691 // to string values. See uses of UnsignedLongToString()
692 // and UnsignedLongToHexString().
694
695private:
696
697 // These are not implemented.
699
701 operator=(const FormatterToXML&);
702
703 bool
704 operator==(const FormatterToXML&) const;
705
706 /**
707 * Append a wide character to the buffer.
708 * Characters that are not representable
709 * in the encoding are not written as
710 * entities.
711 *
712 * @ch the character to append.
713 */
714 void
715 accumNameAsByte(XalanDOMChar ch);
716
717 /**
718 * Append a wide character to the buffer.
719 * Characters that are not representable
720 * in the encoding are not written as
721 * entities.
722 *
723 * @ch the character to append.
724 */
725 void
726 accumNameAsByteDirect(XalanDOMChar ch);
727
728 /**
729 * Append a wide character to the buffer.
730 * Characters that are not representable
731 * in the encoding are written as entities.
732 *
733 * @ch the character to append.
734 */
735 void
736 accumContentAsByte(XalanDOMChar ch);
737
738 /**
739 * Append a wide character to the output.
740 * Characters that are not representable
741 * in the encoding are written as entities.
742 *
743 * @ch the character to append.
744 */
745 void
746 accumContentAsByteDirect(XalanDOMChar ch);
747
748 /**
749 * Append a wide character to the buffer.
750 * Characters that are not representable
751 * in the encoding are not written as
752 * entities.
753 *
754 * @ch the character to append.
755 */
756 void
757 accumNameAsChar(XalanDOMChar ch);
758
759 /**
760 * Append a wide character to the buffer.
761 * Characters that are not representable
762 * in the encoding are not written as
763 * entities.
764 *
765 * @ch the character to append.
766 */
767 void
768 accumNameAsCharDirect(XalanDOMChar ch);
769
770 /**
771 * Append a wide character to the buffer.
772 *
773 * @ch the character to append.
774 */
775 void
776 accumContentAsChar(XalanDOMChar ch);
777
778 /**
779 * Append a wide character to the stream without buffering.
780 *
781 * @ch the character to append.
782 */
783 void
784 accumContentAsCharDirect(XalanDOMChar ch);
785
786 /**
787 * Append a wide character to the buffer.
788 * All characters are representable,
789 * so no checks or escapes are needed.
790 *
791 * @ch the character to append.
792 */
793 void
794 accumCharUTF(XalanDOMChar ch);
795
796 /**
797 * Append a wide character to the output.
798 * All characters are representable,
799 * so no checks or escapes are needed.
800 *
801 * @ch the character to append.
802 */
803 void
804 accumCharUTFDirect(XalanDOMChar ch);
805
806 /**
807 * Append a string to the buffer.
808 * Characters that are not representable
809 * in the encoding are not written as
810 * entities.
811 *
812 * @chars the string to append.
813 */
814 void
815 accumNameString(const XalanDOMChar* chars);
816
817 /**
818 * Append a wide character to the buffer.
819 * All characters are representable,
820 * so no checks or escapes are needed.
821 *
822 * @chars the string to append.
823 */
824 void
825 accumStringUTF(const XalanDOMChar* chars);
826
827 /**
828 * Append a wide character to the output.
829 * All characters are representable,
830 * so no checks or escapes are needed.
831 *
832 * @chars the string to append.
833 */
834 void
835 accumStringUTFDirect(const XalanDOMChar* chars);
836
837 /**
838 * Append a string to the buffer.
839 * Characters that are not representable
840 * in the encoding are written as entities.
841 *
842 * @chars the string to append.
843 */
844 void
845 accumContentString(const XalanDOMChar* chars);
846
847 /**
848 * Append an array of wide character to the buffer.
849 * Characters that are not representable in the
850 * encoding are not written as entities.
851 *
852 * @chars the array to append
853 * @start the offset into the array to start from
854 * @length the number of characters to append
855 */
856 void
857 accumNameArray(
858 const XalanDOMChar chars[],
859 size_type start,
860 size_type length);
861
862 /**
863 * Append an array of wide character to the buffer.
864 * Characters that are not representable in the
865 * encoding are written as entities.
866 *
867 * @chars the array to append
868 * @start the offset into the array to start from
869 * @length the number of characters to append
870 */
871 void
872 accumContentArray(
873 const XalanDOMChar chars[],
874 size_type start,
875 size_type length);
876
877 /**
878 * Append an array of wide character to the buffer.
879 * All characters are representable,
880 * so no checks or escapes are needed.
881 *
882 * @chars the array to append
883 * @start the offset into the array to start from
884 * @length the number of characters to append
885 */
886 void
887 accumArrayUTF(
888 const XalanDOMChar chars[],
889 size_type start,
890 size_type length);
891
892 /**
893 * Append an array of wide character to the output.
894 * All characters are representable,
895 * so no checks or escapes are needed.
896 *
897 * @chars the array to append
898 * @start the offset into the array to start from
899 * @length the number of characters to append
900 */
901 void
902 accumArrayUTFDirect(
903 const XalanDOMChar chars[],
904 size_type start,
905 size_type length);
906
907 /**
908 * Append a string to the buffer.
909 * Characters that are not representable in the
910 * encoding are not written as entities.
911 *
912 * @str the string to append
913 */
914 void
915 accumNameDOMString(const XalanDOMString& str);
916
917 /**
918 * Append a string to the buffer.
919 * Characters that are not representable in the
920 * encoding are written as entities.
921 *
922 * @str the string to append
923 */
924 void
925 accumContentDOMString(const XalanDOMString& str);
926
927 /**
928 * Append a string to the buffer.
929 * All characters are representable,
930 * so no checks or escapes are needed.
931 *
932 * @str the string to append
933 */
934 void
935 accumDOMStringUTF(const XalanDOMString& str);
936
937 /**
938 * Append a string to the output.
939 * All characters are representable,
940 * so no checks or escapes are needed.
941 *
942 * @str the string to append
943 */
944 void
945 accumDOMStringUTFDirect(const XalanDOMString& str);
946
947 /**
948 * Output the doc type declaration.
949 *
950 * @param name the name of the doctype.
951 */
952 void
953 outputDocTypeDecl(const XalanDOMChar* name);
954
955 /**
956 * Process an attribute.
957 * @param name The name of the attribute.
958 * @param value The value of the attribute.
959 */
960 void
961 processAttribute(
962 const XalanDOMChar* name,
963 const XalanDOMChar* value);
964
965 /**
966 * Prints <var>n</var> spaces.
967 * @param n Number of spaces to print.
968 */
969 void
970 printSpace(int n);
971
972 /**
973 * Normalize the data in a PI, to replace any
974 * "?>" pairs with "? >"
975 * @param theData the data to normalize.
976 */
977 void
978 accumNormalizedPIData(
979 const XalanDOMChar* theData,
981
982
983 // Data members...
984 /**
985 * True if an encoding is only has only values from 0 - 255
986 */
987 bool m_bytesEqualChars;
988
989 bool m_shouldFlush;
990
991 /**
992 * Add space before '/>' for XHTML.
993 */
994 bool m_spaceBeforeClose;
995
996 /**
997 * If true, characters in cdata sections are
998 * escaped, instead of being writted out as
999 * cdata sections.
1000 */
1001 bool m_escapeCData;
1002
1003 /**
1004 * Tells the XML version, for writing out to the XML decl.
1005 */
1006 const XalanDOMString m_version;
1007
1008 /**
1009 * Text for standalone part of header.
1010 */
1011 const XalanDOMString m_standalone;
1012
1013 /**
1014 * The media type. Not used right now.
1015 */
1016 const XalanDOMString m_mediaType;
1017
1018 /**
1019 * These are characters that will be escaped in the output.
1020 */
1021 const XalanDOMString m_attrSpecialChars;
1022
1023 //typedef XalanDOMString::size_type size_type;
1024
1025 /**
1026 * The string "<!DOCTYPE ".
1027 */
1028 static const XalanDOMChar s_doctypeHeaderStartString[];
1029
1030 static const size_type s_doctypeHeaderStartStringLength;
1031
1032 /**
1033 * The string " PUBLIC \"".
1034 */
1035 static const XalanDOMChar s_doctypeHeaderPublicString[];
1036
1037 static const size_type s_doctypeHeaderPublicStringLength;
1038
1039 /**
1040 * The string " SYSTEM \"".
1041 */
1042 static const XalanDOMChar s_doctypeHeaderSystemString[];
1043
1044 static const size_type s_doctypeHeaderSystemStringLength;
1045
1046 /**
1047 * The string "<?xml version=\"".
1048 */
1049 static const XalanDOMChar s_xmlHeaderStartString[];
1050
1051 static const size_type s_xmlHeaderStartStringLength;
1052
1053 /**
1054 * The string "\" encoding=\"".
1055 */
1056 static const XalanDOMChar s_xmlHeaderEncodingString[];
1057
1058 static const size_type s_xmlHeaderEncodingStringLength;
1059
1060 /**
1061 * The string "\" standalone=\"".
1062 */
1063 static const XalanDOMChar s_xmlHeaderStandaloneString[];
1064
1065 static const size_type s_xmlHeaderStandaloneStringLength;
1066
1067 /**
1068 * The string "\"?>".
1069 */
1070 static const XalanDOMChar s_xmlHeaderEndString[];
1071
1072 static const size_type s_xmlHeaderEndStringLength;
1073
1074 /**
1075 * The string "1.0".
1076 */
1077 static const XalanDOMChar s_defaultVersionString[];
1078
1079 static const size_type s_defaultVersionStringLength;
1080
1081 /**
1082 * The string "-//W3C//DTD XHTML".
1083 */
1084 static const XalanDOMChar s_xhtmlDocTypeString[];
1085
1086 static const size_type s_xhtmlDocTypeStringLength;
1087
1088 /**
1089 * The string "]]>".
1090 */
1091 static const XalanDOMChar s_dtdCDATACloseString[];
1092
1093 static const size_type s_dtdCDATACloseStringLength;
1094
1095 DOMCharBufferType m_charBuf;
1096
1098
1099 ByteBufferType m_byteBuf;
1100
1101 static const XalanDOMString::size_type s_maxBufferSize;
1102
1103 /**
1104 * A stack of Boolean objects that tell if the given element
1105 * has children.
1106 */
1107 BoolStackType m_elemStack;
1108
1109 /**
1110 * A pointer to a member function that will do accumulating
1111 * for names.
1112 */
1113 AccumCharFunctionType m_accumNameCharFunction;
1114
1115 /**
1116 * A pointer to a member function that will do accumulating
1117 * for names.
1118 */
1119 AccumStringFunctionType m_accumNameStringFunction;
1120
1121 /**
1122 * A pointer to a member function that will do accumulating
1123 * for names.
1124 */
1125 AccumDOMStringFunctionType m_accumNameDOMStringFunction;
1126
1127 /**
1128 * A pointer to a member function that will do accumulating
1129 * for names.
1130 */
1131 AccumArrayFunctionType m_accumNameArrayFunction;
1132
1133 /**
1134 * A pointer to a member function that will do accumulating
1135 * for content.
1136 */
1137 AccumCharFunctionType m_accumContentCharFunction;
1138
1139 /**
1140 * A pointer to a member function that will do accumulating
1141 * for content.
1142 */
1143 AccumStringFunctionType m_accumContentStringFunction;
1144
1145 /**
1146 * A pointer to a member function that will do accumulating
1147 * for content.
1148 */
1149 AccumDOMStringFunctionType m_accumContentDOMStringFunction;
1150
1151 /**
1152 * A pointer to a member function that will do accumulating
1153 * for names.
1154 */
1155 AccumArrayFunctionType m_accumContentArrayFunction;
1156
1157 /**
1158 * A pointer to the member function that will flush the buffer.
1159 */
1160 FlushFunctionType m_flushFunction;
1161
1162 /**
1163 * The string of characters that represents the newline
1164 */
1165 const XalanDOMChar* m_newlineString;
1166
1167 /**
1168 * The length of the the string of characters that represents the newline
1169 */
1170 XalanDOMString::size_type m_newlineStringLength;
1171
1172 bool m_isXML1_1;
1173};
1174
1175
1176
1177}
1178
1179
1180
1181#endif // FORMATTERTOXML_HEADER_GUARD_1357924680
#define XALAN_XMLSUPPORT_EXPORT
#define XALAN_DEFAULT_MEMMGR
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
A SAX-based formatter interface for the XSL processor.
FormatterToXML formats SAX-style events into XML.
static bool isUTF16Surrogate(XalanDOMChar ch)
bool m_nextIsRaw
Tell if the next text should be raw.
void setDoIndent(bool value)
void accumContent(const XalanDOMChar chars[], size_type start, size_type length)
Append an array of wide character to the buffer.
virtual void resetDocument()
size_type accumDefaultEscape(XalanDOMChar ch, size_type i, const XalanDOMChar chars[], size_type len, bool escLF)
Escape and accum a character.
void accumName(const XalanDOMChar *chars)
Append a null-terminated array of wide characters to the buffer.
virtual void cdata(const XMLCh *const ch, const size_type length)
XalanVector< bool > BoolStackType
const XalanDOMString m_doctypeSystem
The System ID for the doc type.
XalanVector< char > ByteBufferType
virtual const XalanDOMString & getEncoding() const
void accumName(const XalanDOMChar chars[], size_type start, size_type length)
Append an array of wide character to the buffer.
XalanDOMChar m_maxCharacter
The maximum character size before we have to resort to escaping.
void flushChars()
Flush the char buffer.
void indent(int n)
Prints a newline character and n spaces.
XalanVector< XalanDOMChar > DOMCharBufferType
virtual const XalanDOMString & getMediaType() const
void initAttrCharsMap()
Set the attribute characters what will require special mapping.
void accumContent(const XalanDOMChar *chars)
Append a null-terminated array of wide characters to the buffer.
virtual bool accumDefaultEntity(XalanDOMChar ch, bool escLF)
Handle one of the default entities, return false if it is not a default entity.
void writeParentTagEnd()
Check to see if a parent's ">" has been written, and, if it has not, write it.
const XalanDOMString m_doctypePublic
The public ID for the doc type.
virtual void endElement(const XMLCh *const name)
virtual void processingInstruction(const XMLCh *const target, const XMLCh *const data)
virtual void writeNormalizedChars(const XalanDOMChar ch[], size_type start, size_type length, bool isCData)
Write normalized characters to the writer.
bool m_stripCData
If true, cdata sections are simply stripped of their CDATA brackets, without escaping.
static void throwInvalidUTF16SurrogateException(XalanDOMChar ch, XalanDOMChar next, MemoryManager &theManager)
Throw an exception when an invalid surrogate is encountered.
void flushBytes()
Flush the byte buffer.
void accumContent(const XalanDOMString &str)
Append a string to the buffer.
static FormatterToXML * create(MemoryManager &theManager, Writer &writer, const XalanDOMString &version=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool doIndent=false, int indent=eDefaultIndentAmount, const XalanDOMString &encoding=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &mediaType=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypeSystem=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypePublic=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool xmlDecl=true, const XalanDOMString &standalone=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), eFormat format=OUTPUT_METHOD_XML, bool fBufferData=true)
void initCharsMap()
Set the output characters what will require special mapping.
MemoryManager & getMemoryManager()
bool m_startNewLine
Flag to signal that a newline should be added.
XalanOutputStream *const m_stream
The stream where the XML will be written.
bool m_doIndent
Flag to tell if indenting (pretty-printing) is on.
void writeNumberedEntityReference(XalanUnicodeChar theNumber)
Write a number into the buffer as an entity reference.
bool m_ispreserve
State flag to tell if preservation of whitespace is important.
virtual void accumCommentData(const XalanDOMChar *data)
Write the data for a comment.
bool m_isprevtext
State flag that tells if the previous node processed was text, so we can tell if we should preserve w...
virtual void writeAttrString(const XalanDOMChar *theString, size_type theStringLength)
Write an attribute string.
void accumName(XalanDOMChar ch)
Append a wide character to the buffer.
virtual const XalanDOMString & getDoctypeSystem() const
const XalanDOMString & getVersion() const
virtual void ignorableWhitespace(const XMLCh *const chars, const size_type length)
static void throwInvalidCharacterException(XalanUnicodeChar ch, MemoryManager &theManager)
Throw an exception when an invalid XML character is encountered.
virtual const XalanDOMString & getDoctypePublic() const
virtual Writer * getWriter() const
XalanDOMString m_stringBuffer
bool m_needToOutputDocTypeDecl
Flag to tell that we need to add the doctype decl, which we can't do until the first element is encou...
virtual void entityReference(const XMLCh *const name)
Receive notification of a entityReference.
virtual int getIndent() const
virtual void charactersRaw(const XMLCh *const chars, const size_type length)
virtual void startElement(const XMLCh *const name, AttributeListType &attrs)
const XalanDOMString & getStandalone() const
FormatterToXML(Writer &writer, const XalanDOMString &version=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool doIndent=false, int indent=eDefaultIndentAmount, const XalanDOMString &encoding=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &mediaType=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypeSystem=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), const XalanDOMString &doctypePublic=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), bool xmlDecl=true, const XalanDOMString &standalone=XalanDOMString(XalanMemMgrs::getDummyMemMgr()), eFormat format=OUTPUT_METHOD_XML, bool fBufferData=true, MemoryManager &theManager XALAN_DEFAULT_MEMMGR)
Constructor for customized encoding and doctype.
bool getShouldWriteXMLHeader() const
virtual void characters(const XMLCh *const chars, const size_type length)
int m_currentIndent
Flag to keep track of the indent amount.
Writer *const m_writer
The writer where the XML will be written.
bool m_encodingIsUTF
Flag to quickly tell if the encoding is capable of full Unicode support.
void setShouldWriteXMLHeader(bool b)
bool m_shouldWriteXMLHeader
If true, XML header should be written to output.
int m_indent
Amount to indent.
BoolStackType m_preserves
Stack to keep track of whether or not we need to preserve whitespace.
static void throwInvalidUTF16SurrogateException(XalanDOMChar ch, MemoryManager &theManager)
Throw an exception when an invalid surrogate is encountered.
void outputLineSep()
Output a line break.
virtual void setDocumentLocator(const Locator *const locator)
void accumContent(XalanDOMChar ch)
Append a wide character to the buffer.
XalanDOMString m_encoding
The character encoding.
virtual void endDocument()
virtual void startDocument()
bool m_inCData
Tells if we're in CData section.
virtual void comment(const XMLCh *const data)
Called when a Comment is to be constructed.
void accumName(const XalanDOMString &str)
Append a string to the buffer.
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
size_t size_type
Definition XalanMap.hpp:46
xercesc::AttributeList AttributeListType
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)