00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(FORMATTERTOXML_HEADER_GUARD_1357924680) 00019 #define FORMATTERTOXML_HEADER_GUARD_1357924680 00020 00021 00022 00023 00024 // Base include file. Must be first. 00025 #include <xalanc/XMLSupport/XMLSupportDefinitions.hpp> 00026 00027 00028 00029 #include <xalanc/Include/XalanVector.hpp> 00030 00031 00032 00033 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00034 00035 00036 00037 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00038 #include <xalanc/PlatformSupport/XalanUnicode.hpp> 00039 00040 00041 00042 // Base class header file. 00043 #include <xalanc/PlatformSupport/FormatterListener.hpp> 00044 00045 00046 00047 XALAN_CPP_NAMESPACE_BEGIN 00048 00049 00050 00051 class Writer; 00052 class XalanOutputStream; 00053 00054 00055 00056 /** 00057 * FormatterToXML formats SAX-style events into XML. 00058 */ 00059 class XALAN_XMLSUPPORT_EXPORT FormatterToXML : public FormatterListener 00060 { 00061 public: 00062 00063 enum eDummy 00064 { 00065 eDefaultIndentAmount = 0 00066 }; 00067 00068 /** 00069 * Constructor for customized encoding and doctype. 00070 * 00071 * @param writer character output stream to use 00072 * @param version version of the output method 00073 * @param doIndent true if output is to be indented 00074 * @param indent number of spaces to indent at each nesting level 00075 * @param encoding character encoding in use by <VAR>writer</VAR> 00076 * @param mediaType media type (MIME content type) of the data 00077 * @param doctypeSystem system identifier to be used in the document 00078 * type declaration 00079 * @param doctypePublic public identifier to be used in the document 00080 * type declaration 00081 * @param xmlDecl true if the XSLT processor should output an XML 00082 * declaration 00083 * @param standalone true if the XSLT processor should output a 00084 * standalone document declaration 00085 * 00086 * @param format should be used only by derived classes. 00087 * @param fBufferData If true, data will be buffered in the formatter 00088 */ 00089 FormatterToXML( 00090 Writer& writer, 00091 const XalanDOMString& version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00092 bool doIndent = false, 00093 int indent = eDefaultIndentAmount, 00094 const XalanDOMString& encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00095 const XalanDOMString& mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00096 const XalanDOMString& doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00097 const XalanDOMString& doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00098 bool xmlDecl = true, 00099 const XalanDOMString& standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00100 eFormat format = OUTPUT_METHOD_XML, 00101 bool fBufferData = true, 00102 MemoryManager& theManager XALAN_DEFAULT_MEMMGR); 00103 00104 static FormatterToXML* 00105 create( 00106 MemoryManager& theManager, 00107 Writer& writer, 00108 const XalanDOMString& version = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00109 bool doIndent = false, 00110 int indent = eDefaultIndentAmount, 00111 const XalanDOMString& encoding = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00112 const XalanDOMString& mediaType = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00113 const XalanDOMString& doctypeSystem = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00114 const XalanDOMString& doctypePublic = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00115 bool xmlDecl = true, 00116 const XalanDOMString& standalone = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00117 eFormat format = OUTPUT_METHOD_XML, 00118 bool fBufferData = true); 00119 00120 virtual 00121 ~FormatterToXML(); 00122 00123 MemoryManager& 00124 getMemoryManager() 00125 { 00126 return m_stringBuffer.getMemoryManager(); 00127 } 00128 00129 // These methods are inherited from FormatterListener ... 00130 00131 virtual void 00132 setDocumentLocator(const Locator* const locator); 00133 00134 virtual void 00135 startDocument(); 00136 00137 virtual void 00138 endDocument(); 00139 00140 virtual void 00141 startElement( 00142 const XMLCh* const name, 00143 AttributeListType& attrs); 00144 00145 virtual void 00146 endElement(const XMLCh* const name); 00147 00148 virtual void 00149 characters( 00150 const XMLCh* const chars, 00151 const size_type length); 00152 00153 virtual void 00154 charactersRaw( 00155 const XMLCh* const chars, 00156 const size_type length); 00157 00158 virtual void 00159 entityReference(const XMLCh* const name); 00160 00161 virtual void 00162 ignorableWhitespace( 00163 const XMLCh* const chars, 00164 const size_type length); 00165 00166 virtual void 00167 processingInstruction( 00168 const XMLCh* const target, 00169 const XMLCh* const data); 00170 00171 00172 virtual void 00173 resetDocument(); 00174 00175 virtual void 00176 comment(const XMLCh* const data); 00177 00178 virtual void 00179 cdata( 00180 const XMLCh* const ch, 00181 const size_type length); 00182 00183 virtual Writer* 00184 getWriter() const; 00185 00186 virtual const XalanDOMString& 00187 getDoctypeSystem() const; 00188 00189 virtual const XalanDOMString& 00190 getDoctypePublic() const; 00191 00192 virtual const XalanDOMString& 00193 getEncoding() const; 00194 00195 virtual const XalanDOMString& 00196 getMediaType() const; 00197 00198 virtual int 00199 getIndent() const; 00200 00201 const XalanDOMString& 00202 getVersion() const 00203 { 00204 return m_version; 00205 } 00206 00207 const XalanDOMString& 00208 getStandalone() const 00209 { 00210 return m_standalone; 00211 } 00212 00213 bool 00214 getShouldWriteXMLHeader() const 00215 { 00216 return m_shouldWriteXMLHeader; 00217 } 00218 00219 void 00220 setShouldWriteXMLHeader(bool b) 00221 { 00222 m_shouldWriteXMLHeader = b; 00223 } 00224 00225 bool 00226 getStripCData() const 00227 { 00228 return m_stripCData; 00229 } 00230 00231 void 00232 setStripCData(bool b) 00233 { 00234 m_stripCData = b; 00235 } 00236 00237 bool 00238 getEscapeCData() const 00239 { 00240 return m_escapeCData; 00241 } 00242 00243 void 00244 setEscapeCData(bool b) 00245 { 00246 m_escapeCData = b; 00247 } 00248 00249 bool 00250 getDoIndent() const 00251 { 00252 return m_doIndent; 00253 } 00254 00255 void 00256 setDoIndent(bool value) 00257 { 00258 m_doIndent = value; 00259 } 00260 00261 void 00262 setIndent(int value) 00263 { 00264 m_indent = value; 00265 } 00266 00267 00268 typedef XalanVector<bool> BoolStackType; 00269 typedef XalanVector<XalanDOMChar> DOMCharBufferType; 00270 typedef XalanVector<char> ByteBufferType; 00271 00272 00273 protected: 00274 00275 /** 00276 * The writer where the XML will be written. 00277 */ 00278 Writer* const m_writer; 00279 00280 /** 00281 * The stream where the XML will be written. 00282 */ 00283 XalanOutputStream* const m_stream; 00284 00285 /** 00286 * Output a line break. 00287 */ 00288 void 00289 outputLineSep(); 00290 00291 typedef void (FormatterToXML::*AccumCharFunctionType)(XalanDOMChar); 00292 00293 typedef void (FormatterToXML::*AccumStringFunctionType)(const XalanDOMChar*); 00294 00295 typedef void (FormatterToXML::*AccumDOMStringFunctionType)(const XalanDOMString&); 00296 00297 typedef void (FormatterToXML::*AccumArrayFunctionType)( 00298 const XalanDOMChar[], 00299 size_type, 00300 size_type); 00301 00302 typedef void (FormatterToXML::*FlushFunctionType)(); 00303 00304 /** 00305 * Append a wide character to the buffer. 00306 * 00307 * Characters that are not representable 00308 * in the encoding are not written as 00309 * entities. 00310 * 00311 * @ch the character to append. 00312 */ 00313 void 00314 accumName(XalanDOMChar ch) 00315 { 00316 assert(m_accumNameCharFunction != 0); 00317 00318 (this->*m_accumNameCharFunction)(ch); 00319 } 00320 00321 /** 00322 * Append a wide character to the buffer. 00323 * 00324 * @ch the character to append. 00325 */ 00326 void 00327 accumContent(XalanDOMChar ch) 00328 { 00329 assert(m_accumContentCharFunction != 0); 00330 00331 (this->*m_accumContentCharFunction)(ch); 00332 } 00333 00334 /** 00335 * Append a null-terminated array of wide characters to 00336 * the buffer. 00337 * 00338 * Characters that are not representable 00339 * in the encoding are not written as 00340 * entities. 00341 * 00342 * @chars the array to append 00343 */ 00344 void 00345 accumName(const XalanDOMChar* chars) 00346 { 00347 assert(m_accumNameStringFunction != 0); 00348 00349 (this->*m_accumNameStringFunction)(chars); 00350 } 00351 00352 /** 00353 * Append a null-terminated array of wide characters to 00354 * the buffer. 00355 * 00356 * @chars the array to append 00357 */ 00358 void 00359 accumContent(const XalanDOMChar* chars) 00360 { 00361 assert(m_accumContentStringFunction != 0); 00362 00363 (this->*m_accumContentStringFunction)(chars); 00364 } 00365 00366 /** 00367 * Append an array of wide character to the buffer. 00368 * 00369 * Characters that are not representable 00370 * in the encoding are not written as 00371 * entities. 00372 * 00373 * @chars the array to append 00374 * @start the offset into the array to start from 00375 * @length the number of characters to append 00376 */ 00377 void 00378 accumName( 00379 const XalanDOMChar chars[], 00380 size_type start, 00381 size_type length) 00382 { 00383 assert(m_accumNameArrayFunction != 0); 00384 00385 (this->*m_accumNameArrayFunction)(chars, start, length); 00386 } 00387 00388 /** 00389 * Append an array of wide character to the buffer. 00390 * 00391 * @chars the array to append 00392 * @start the offset into the array to start from 00393 * @length the number of characters to append 00394 */ 00395 void 00396 accumContent( 00397 const XalanDOMChar chars[], 00398 size_type start, 00399 size_type length) 00400 { 00401 assert(m_accumContentArrayFunction != 0); 00402 00403 (this->*m_accumContentArrayFunction)(chars, start, length); 00404 } 00405 00406 /** 00407 * Append a string to the buffer. 00408 * 00409 * Characters that are not representable 00410 * in the encoding are not written as 00411 * entities. 00412 * 00413 * @param str the string to append 00414 */ 00415 void 00416 accumName(const XalanDOMString& str) 00417 { 00418 assert(m_accumNameDOMStringFunction != 0); 00419 00420 (this->*m_accumNameDOMStringFunction)(str); 00421 } 00422 00423 /** 00424 * Append a string to the buffer. 00425 * 00426 * @param str the string to append 00427 */ 00428 void 00429 accumContent(const XalanDOMString& str) 00430 { 00431 assert(m_accumContentDOMStringFunction != 0); 00432 00433 (this->*m_accumContentDOMStringFunction)(str); 00434 } 00435 00436 /** 00437 * Escape and accum a character. 00438 */ 00439 size_type 00440 accumDefaultEscape( 00441 XalanDOMChar ch, 00442 size_type i, 00443 const XalanDOMChar chars[], 00444 size_type len, 00445 bool escLF); 00446 00447 /** 00448 * Handle one of the default entities, return false if it 00449 * is not a default entity. 00450 */ 00451 virtual bool 00452 accumDefaultEntity( 00453 XalanDOMChar ch, 00454 bool escLF); 00455 00456 /** 00457 * Set the attribute characters what will require special mapping. 00458 */ 00459 void 00460 initAttrCharsMap(); 00461 00462 /** 00463 * Set the output characters what will require special mapping. 00464 */ 00465 void 00466 initCharsMap(); 00467 00468 /** 00469 * Flush the char buffer. 00470 */ 00471 void 00472 flushChars(); 00473 00474 /** 00475 * Flush the byte buffer. 00476 */ 00477 void 00478 flushBytes(); 00479 00480 void 00481 flushWriter(); 00482 00483 void 00484 openElementForChildren(); 00485 00486 bool 00487 childNodesWereAdded(); 00488 00489 bool 00490 shouldIndent() const 00491 { 00492 return m_doIndent && (!m_ispreserve && !m_isprevtext); 00493 } 00494 00495 /** 00496 * Check to see if a parent's ">" has been written, and, if 00497 * it has not, write it. 00498 */ 00499 void 00500 writeParentTagEnd(); 00501 00502 /** 00503 * Prints a newline character and <var>n</var> spaces. 00504 * @param n Number of spaces to print. 00505 */ 00506 void 00507 indent(int n); 00508 00509 /** 00510 * Write normalized characters to the writer. 00511 * @param ch the string to write. 00512 * @param start the start offset into the string. 00513 * @param length the length of the string. 00514 * @param isCData true if writing CDATA. 00515 */ 00516 virtual void 00517 writeNormalizedChars( 00518 const XalanDOMChar ch[], 00519 size_type start, 00520 size_type length, 00521 bool isCData); 00522 00523 /** 00524 * Write a number into the buffer as an entity 00525 * reference. 00526 * @param theNumber the number to write. 00527 */ 00528 void 00529 writeNumberedEntityReference(XalanUnicodeChar theNumber); 00530 00531 /** 00532 * Write an attribute string. 00533 * 00534 * @param theString The string to write. 00535 * @param theStringLength The length of the string. 00536 */ 00537 virtual void 00538 writeAttrString( 00539 const XalanDOMChar* theString, 00540 size_type theStringLength); 00541 00542 /** 00543 * Write the data for a comment 00544 * @param data The comment's data. 00545 */ 00546 virtual void 00547 accumCommentData(const XalanDOMChar* data); 00548 00549 /** 00550 * Throw an exception when an invalid 00551 * surrogate is encountered. 00552 * @param ch The first character in the surrogate 00553 * @param theManager The MemoryManager instance to use 00554 */ 00555 static void 00556 throwInvalidUTF16SurrogateException( 00557 XalanDOMChar ch, 00558 MemoryManager& theManager); 00559 00560 /** 00561 * Throw an exception when an invalid 00562 * surrogate is encountered. 00563 * @param ch The first character in the surrogate 00564 * @param next The next character in the surrogate 00565 * @param theManager The MemoryManager instance to use 00566 */ 00567 static void 00568 throwInvalidUTF16SurrogateException( 00569 XalanDOMChar ch, 00570 XalanDOMChar next, 00571 MemoryManager& theManager); 00572 00573 00574 /** 00575 * Throw an exception when an invalid 00576 * XML character is encountered. 00577 * @param ch The first character in the surrogate 00578 * @param next The next character in the surrogate 00579 */ 00580 static void 00581 throwInvalidCharacterException( 00582 XalanUnicodeChar ch, 00583 MemoryManager& theManager); 00584 00585 static bool 00586 isUTF16Surrogate(XalanDOMChar ch) 00587 { 00588 return (ch & 0xFC00) == 0xD800 ? true : false; 00589 } 00590 00591 enum eDummyTwo { SPECIALSSIZE = 256}; 00592 00593 /** 00594 * The maximum character size before we have to resort 00595 * to escaping. 00596 */ 00597 XalanDOMChar m_maxCharacter; 00598 00599 XalanDOMChar m_attrCharsMap[SPECIALSSIZE]; 00600 00601 XalanDOMChar m_charsMap[SPECIALSSIZE]; 00602 00603 /** 00604 * If true, XML header should be written to output. 00605 */ 00606 bool m_shouldWriteXMLHeader; 00607 00608 /** 00609 * State flag to tell if preservation of whitespace 00610 * is important. 00611 */ 00612 bool m_ispreserve; 00613 00614 /** 00615 * Flag to tell if indenting (pretty-printing) is on. 00616 */ 00617 bool m_doIndent; 00618 00619 /** 00620 * Flag to signal that a newline should be added. 00621 */ 00622 bool m_startNewLine; 00623 00624 /** 00625 * Flag to tell that we need to add the doctype decl, 00626 * which we can't do until the first element is 00627 * encountered. 00628 */ 00629 bool m_needToOutputDocTypeDecl; 00630 00631 /** 00632 * State flag that tells if the previous node processed 00633 * was text, so we can tell if we should preserve whitespace. 00634 */ 00635 bool m_isprevtext; 00636 00637 /** 00638 * If true, cdata sections are simply stripped of their 00639 * CDATA brackets, without escaping. 00640 */ 00641 bool m_stripCData; 00642 00643 /** 00644 * Tell if the next text should be raw. 00645 */ 00646 bool m_nextIsRaw; 00647 00648 /** 00649 * Tells if we're in CData section. 00650 */ 00651 bool m_inCData; 00652 00653 /** 00654 * Flag to quickly tell if the encoding is capable of full 00655 * Unicode support. 00656 */ 00657 bool m_encodingIsUTF; 00658 00659 /** 00660 * The System ID for the doc type. 00661 */ 00662 const XalanDOMString m_doctypeSystem; 00663 00664 /** 00665 * The public ID for the doc type. 00666 */ 00667 const XalanDOMString m_doctypePublic; 00668 00669 /** 00670 * The character encoding. 00671 */ 00672 XalanDOMString m_encoding; 00673 00674 /** 00675 * Flag to keep track of the indent amount. 00676 */ 00677 int m_currentIndent; 00678 00679 /** 00680 * Amount to indent. 00681 */ 00682 int m_indent; 00683 00684 /** 00685 * Stack to keep track of whether or not we need to 00686 * preserve whitespace. 00687 */ 00688 BoolStackType m_preserves; 00689 00690 // A text buffer. We use it mostly for converting 00691 // to string values. See uses of UnsignedLongToString() 00692 // and UnsignedLongToHexString(). 00693 XalanDOMString m_stringBuffer; 00694 00695 private: 00696 00697 // These are not implemented. 00698 FormatterToXML(const FormatterToXML&); 00699 00700 FormatterToXML& 00701 operator=(const FormatterToXML&); 00702 00703 bool 00704 operator==(const FormatterToXML&) const; 00705 00706 /** 00707 * Append a wide character to the buffer. 00708 * Characters that are not representable 00709 * in the encoding are not written as 00710 * entities. 00711 * 00712 * @ch the character to append. 00713 */ 00714 void 00715 accumNameAsByte(XalanDOMChar ch); 00716 00717 /** 00718 * Append a wide character to the buffer. 00719 * Characters that are not representable 00720 * in the encoding are not written as 00721 * entities. 00722 * 00723 * @ch the character to append. 00724 */ 00725 void 00726 accumNameAsByteDirect(XalanDOMChar ch); 00727 00728 /** 00729 * Append a wide character to the buffer. 00730 * Characters that are not representable 00731 * in the encoding are written as entities. 00732 * 00733 * @ch the character to append. 00734 */ 00735 void 00736 accumContentAsByte(XalanDOMChar ch); 00737 00738 /** 00739 * Append a wide character to the output. 00740 * Characters that are not representable 00741 * in the encoding are written as entities. 00742 * 00743 * @ch the character to append. 00744 */ 00745 void 00746 accumContentAsByteDirect(XalanDOMChar ch); 00747 00748 /** 00749 * Append a wide character to the buffer. 00750 * Characters that are not representable 00751 * in the encoding are not written as 00752 * entities. 00753 * 00754 * @ch the character to append. 00755 */ 00756 void 00757 accumNameAsChar(XalanDOMChar ch); 00758 00759 /** 00760 * Append a wide character to the buffer. 00761 * Characters that are not representable 00762 * in the encoding are not written as 00763 * entities. 00764 * 00765 * @ch the character to append. 00766 */ 00767 void 00768 accumNameAsCharDirect(XalanDOMChar ch); 00769 00770 /** 00771 * Append a wide character to the buffer. 00772 * 00773 * @ch the character to append. 00774 */ 00775 void 00776 accumContentAsChar(XalanDOMChar ch); 00777 00778 /** 00779 * Append a wide character to the stream without buffering. 00780 * 00781 * @ch the character to append. 00782 */ 00783 void 00784 accumContentAsCharDirect(XalanDOMChar ch); 00785 00786 /** 00787 * Append a wide character to the buffer. 00788 * All characters are representable, 00789 * so no checks or escapes are needed. 00790 * 00791 * @ch the character to append. 00792 */ 00793 void 00794 accumCharUTF(XalanDOMChar ch); 00795 00796 /** 00797 * Append a wide character to the output. 00798 * All characters are representable, 00799 * so no checks or escapes are needed. 00800 * 00801 * @ch the character to append. 00802 */ 00803 void 00804 accumCharUTFDirect(XalanDOMChar ch); 00805 00806 /** 00807 * Append a string to the buffer. 00808 * Characters that are not representable 00809 * in the encoding are not written as 00810 * entities. 00811 * 00812 * @chars the string to append. 00813 */ 00814 void 00815 accumNameString(const XalanDOMChar* chars); 00816 00817 /** 00818 * Append a wide character to the buffer. 00819 * All characters are representable, 00820 * so no checks or escapes are needed. 00821 * 00822 * @chars the string to append. 00823 */ 00824 void 00825 accumStringUTF(const XalanDOMChar* chars); 00826 00827 /** 00828 * Append a wide character to the output. 00829 * All characters are representable, 00830 * so no checks or escapes are needed. 00831 * 00832 * @chars the string to append. 00833 */ 00834 void 00835 accumStringUTFDirect(const XalanDOMChar* chars); 00836 00837 /** 00838 * Append a string to the buffer. 00839 * Characters that are not representable 00840 * in the encoding are written as entities. 00841 * 00842 * @chars the string to append. 00843 */ 00844 void 00845 accumContentString(const XalanDOMChar* chars); 00846 00847 /** 00848 * Append an array of wide character to the buffer. 00849 * Characters that are not representable in the 00850 * encoding are not written as entities. 00851 * 00852 * @chars the array to append 00853 * @start the offset into the array to start from 00854 * @length the number of characters to append 00855 */ 00856 void 00857 accumNameArray( 00858 const XalanDOMChar chars[], 00859 size_type start, 00860 size_type length); 00861 00862 /** 00863 * Append an array of wide character to the buffer. 00864 * Characters that are not representable in the 00865 * encoding are written as entities. 00866 * 00867 * @chars the array to append 00868 * @start the offset into the array to start from 00869 * @length the number of characters to append 00870 */ 00871 void 00872 accumContentArray( 00873 const XalanDOMChar chars[], 00874 size_type start, 00875 size_type length); 00876 00877 /** 00878 * Append an array of wide character to the buffer. 00879 * All characters are representable, 00880 * so no checks or escapes are needed. 00881 * 00882 * @chars the array to append 00883 * @start the offset into the array to start from 00884 * @length the number of characters to append 00885 */ 00886 void 00887 accumArrayUTF( 00888 const XalanDOMChar chars[], 00889 size_type start, 00890 size_type length); 00891 00892 /** 00893 * Append an array of wide character to the output. 00894 * All characters are representable, 00895 * so no checks or escapes are needed. 00896 * 00897 * @chars the array to append 00898 * @start the offset into the array to start from 00899 * @length the number of characters to append 00900 */ 00901 void 00902 accumArrayUTFDirect( 00903 const XalanDOMChar chars[], 00904 size_type start, 00905 size_type length); 00906 00907 /** 00908 * Append a string to the buffer. 00909 * Characters that are not representable in the 00910 * encoding are not written as entities. 00911 * 00912 * @str the string to append 00913 */ 00914 void 00915 accumNameDOMString(const XalanDOMString& str); 00916 00917 /** 00918 * Append a string to the buffer. 00919 * Characters that are not representable in the 00920 * encoding are written as entities. 00921 * 00922 * @str the string to append 00923 */ 00924 void 00925 accumContentDOMString(const XalanDOMString& str); 00926 00927 /** 00928 * Append a string to the buffer. 00929 * All characters are representable, 00930 * so no checks or escapes are needed. 00931 * 00932 * @str the string to append 00933 */ 00934 void 00935 accumDOMStringUTF(const XalanDOMString& str); 00936 00937 /** 00938 * Append a string to the output. 00939 * All characters are representable, 00940 * so no checks or escapes are needed. 00941 * 00942 * @str the string to append 00943 */ 00944 void 00945 accumDOMStringUTFDirect(const XalanDOMString& str); 00946 00947 /** 00948 * Output the doc type declaration. 00949 * 00950 * @param name the name of the doctype. 00951 */ 00952 void 00953 outputDocTypeDecl(const XalanDOMChar* name); 00954 00955 /** 00956 * Process an attribute. 00957 * @param name The name of the attribute. 00958 * @param value The value of the attribute. 00959 */ 00960 void 00961 processAttribute( 00962 const XalanDOMChar* name, 00963 const XalanDOMChar* value); 00964 00965 /** 00966 * Prints <var>n</var> spaces. 00967 * @param n Number of spaces to print. 00968 */ 00969 void 00970 printSpace(int n); 00971 00972 /** 00973 * Normalize the data in a PI, to replace any 00974 * "?>" pairs with "? >" 00975 * @param theData the data to normalize. 00976 */ 00977 void 00978 accumNormalizedPIData( 00979 const XalanDOMChar* theData, 00980 size_type theLength); 00981 00982 00983 // Data members... 00984 /** 00985 * True if an encoding is only has only values from 0 - 255 00986 */ 00987 bool m_bytesEqualChars; 00988 00989 bool m_shouldFlush; 00990 00991 /** 00992 * Add space before '/>' for XHTML. 00993 */ 00994 bool m_spaceBeforeClose; 00995 00996 /** 00997 * If true, characters in cdata sections are 00998 * escaped, instead of being writted out as 00999 * cdata sections. 01000 */ 01001 bool m_escapeCData; 01002 01003 /** 01004 * Tells the XML version, for writing out to the XML decl. 01005 */ 01006 const XalanDOMString m_version; 01007 01008 /** 01009 * Text for standalone part of header. 01010 */ 01011 const XalanDOMString m_standalone; 01012 01013 /** 01014 * The media type. Not used right now. 01015 */ 01016 const XalanDOMString m_mediaType; 01017 01018 /** 01019 * These are characters that will be escaped in the output. 01020 */ 01021 const XalanDOMString m_attrSpecialChars; 01022 01023 //typedef XalanDOMString::size_type size_type; 01024 01025 /** 01026 * The string "<!DOCTYPE ". 01027 */ 01028 static const XalanDOMChar s_doctypeHeaderStartString[]; 01029 01030 static const size_type s_doctypeHeaderStartStringLength; 01031 01032 /** 01033 * The string " PUBLIC \"". 01034 */ 01035 static const XalanDOMChar s_doctypeHeaderPublicString[]; 01036 01037 static const size_type s_doctypeHeaderPublicStringLength; 01038 01039 /** 01040 * The string " SYSTEM \"". 01041 */ 01042 static const XalanDOMChar s_doctypeHeaderSystemString[]; 01043 01044 static const size_type s_doctypeHeaderSystemStringLength; 01045 01046 /** 01047 * The string "<?xml version=\"". 01048 */ 01049 static const XalanDOMChar s_xmlHeaderStartString[]; 01050 01051 static const size_type s_xmlHeaderStartStringLength; 01052 01053 /** 01054 * The string "\" encoding=\"". 01055 */ 01056 static const XalanDOMChar s_xmlHeaderEncodingString[]; 01057 01058 static const size_type s_xmlHeaderEncodingStringLength; 01059 01060 /** 01061 * The string "\" standalone=\"". 01062 */ 01063 static const XalanDOMChar s_xmlHeaderStandaloneString[]; 01064 01065 static const size_type s_xmlHeaderStandaloneStringLength; 01066 01067 /** 01068 * The string "\"?>". 01069 */ 01070 static const XalanDOMChar s_xmlHeaderEndString[]; 01071 01072 static const size_type s_xmlHeaderEndStringLength; 01073 01074 /** 01075 * The string "1.0". 01076 */ 01077 static const XalanDOMChar s_defaultVersionString[]; 01078 01079 static const size_type s_defaultVersionStringLength; 01080 01081 /** 01082 * The string "-//W3C//DTD XHTML". 01083 */ 01084 static const XalanDOMChar s_xhtmlDocTypeString[]; 01085 01086 static const size_type s_xhtmlDocTypeStringLength; 01087 01088 /** 01089 * The string "]]>". 01090 */ 01091 static const XalanDOMChar s_dtdCDATACloseString[]; 01092 01093 static const size_type s_dtdCDATACloseStringLength; 01094 01095 DOMCharBufferType m_charBuf; 01096 01097 XalanDOMString::size_type m_pos; 01098 01099 ByteBufferType m_byteBuf; 01100 01101 static const XalanDOMString::size_type s_maxBufferSize; 01102 01103 /** 01104 * A stack of Boolean objects that tell if the given element 01105 * has children. 01106 */ 01107 BoolStackType m_elemStack; 01108 01109 /** 01110 * A pointer to a member function that will do accumulating 01111 * for names. 01112 */ 01113 AccumCharFunctionType m_accumNameCharFunction; 01114 01115 /** 01116 * A pointer to a member function that will do accumulating 01117 * for names. 01118 */ 01119 AccumStringFunctionType m_accumNameStringFunction; 01120 01121 /** 01122 * A pointer to a member function that will do accumulating 01123 * for names. 01124 */ 01125 AccumDOMStringFunctionType m_accumNameDOMStringFunction; 01126 01127 /** 01128 * A pointer to a member function that will do accumulating 01129 * for names. 01130 */ 01131 AccumArrayFunctionType m_accumNameArrayFunction; 01132 01133 /** 01134 * A pointer to a member function that will do accumulating 01135 * for content. 01136 */ 01137 AccumCharFunctionType m_accumContentCharFunction; 01138 01139 /** 01140 * A pointer to a member function that will do accumulating 01141 * for content. 01142 */ 01143 AccumStringFunctionType m_accumContentStringFunction; 01144 01145 /** 01146 * A pointer to a member function that will do accumulating 01147 * for content. 01148 */ 01149 AccumDOMStringFunctionType m_accumContentDOMStringFunction; 01150 01151 /** 01152 * A pointer to a member function that will do accumulating 01153 * for names. 01154 */ 01155 AccumArrayFunctionType m_accumContentArrayFunction; 01156 01157 /** 01158 * A pointer to the member function that will flush the buffer. 01159 */ 01160 FlushFunctionType m_flushFunction; 01161 01162 /** 01163 * The string of characters that represents the newline 01164 */ 01165 const XalanDOMChar* m_newlineString; 01166 01167 /** 01168 * The length of the the string of characters that represents the newline 01169 */ 01170 XalanDOMString::size_type m_newlineStringLength; 01171 01172 bool m_isXML1_1; 01173 }; 01174 01175 01176 01177 XALAN_CPP_NAMESPACE_END 01178 01179 01180 01181 #endif // FORMATTERTOXML_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|