blob: 1fe1093539242da933cd3059ee82e073f8406a75 [file] [log] [blame]
<HTML><HEAD><TITLE>Xalan-C++ API Documentation</TITLE></HEAD>
<BODY>
<h2 align="center">Xalan-C++ API Documentation</h2>
<h3 align="center">The Xalan C++ XSLT Processor Version 1.10</h3>
</BODY>
<!-- Generated by Doxygen 1.2.8.1 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
<hr><h1>FormatterToXMLUnicode.hpp</h1><a href="FormatterToXMLUnicode_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/*</font>
00002 <font class="comment"> * Copyright 1999-2004 The Apache Software Foundation.</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</font>
00005 <font class="comment"> * you may not use this file except in compliance with the License.</font>
00006 <font class="comment"> * You may obtain a copy of the License at</font>
00007 <font class="comment"> *</font>
00008 <font class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</font>
00009 <font class="comment"> *</font>
00010 <font class="comment"> * Unless required by applicable law or agreed to in writing, software</font>
00011 <font class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</font>
00012 <font class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</font>
00013 <font class="comment"> * See the License for the specific language governing permissions and</font>
00014 <font class="comment"> * limitations under the License.</font>
00015 <font class="comment"> */</font>
00016 <font class="preprocessor">#if !defined(FORMATTERTOXML_UNICODE_HEADER_GUARD_1357924680)</font>
<a name="l00017"></a><a class="code" href="FormatterToXMLUnicode_8hpp.html#a0">00017</a> <font class="preprocessor"></font><font class="preprocessor">#define FORMATTERTOXML_UNICODE_HEADER_GUARD_1357924680</font>
00018 <font class="preprocessor"></font>
00019
00020 <font class="comment">// Base include file. Must be first.</font>
00021 <font class="preprocessor">#include "<a class="code" href="XMLSupportDefinitions_8hpp.html">xalanc/XMLSupport/XMLSupportDefinitions.hpp</a>"</font>
00022
00023
00024
00025 <font class="preprocessor">#include "<a class="code" href="XalanXMLSerializerBase_8hpp.html">xalanc/XMLSupport/XalanXMLSerializerBase.hpp</a>"</font>
00026
00027
00028
00029 <font class="preprocessor">#include "xercesc/sax/AttributeList.hpp"</font>
00030
00031
00032
00033 <font class="preprocessor">#include "<a class="code" href="DoubleSupport_8hpp.html">xalanc/PlatformSupport/DoubleSupport.hpp</a>"</font>
00034 <font class="preprocessor">#include "<a class="code" href="XalanOutputStream_8hpp.html">xalanc/PlatformSupport/XalanOutputStream.hpp</a>"</font>
00035 <font class="preprocessor">#include "<a class="code" href="XalanUnicode_8hpp.html">xalanc/PlatformSupport/XalanUnicode.hpp</a>"</font>
00036
00037
00038
00039 <font class="preprocessor">#include &lt;<a class="code" href="DOMServices_8hpp.html">xalanc/DOMSupport/DOMServices.hpp</a>&gt;</font>
00040
00041
00042
00043 XALAN_CPP_NAMESPACE_BEGIN
00044
00045
00049 <font class="keyword">template</font>&lt;
00050 <font class="keyword">class </font>UnicodeWriter,
00051 <font class="keyword">class </font>ConstantsType,
00052 <font class="keyword">class </font>CharPredicate,
00053 <font class="keyword">class </font>IndentHandler,
00054 FormatterListener::eXMLVersion XMLVersion&gt;
<a name="l00055"></a><a class="code" href="classFormatterToXMLUnicode.html">00055</a> <font class="keyword">class </font>XALAN_XMLSUPPORT_EXPORT <a class="code" href="classFormatterToXMLUnicode.html">FormatterToXMLUnicode</a> : <font class="keyword">public</font> <a class="code" href="classXalanXMLSerializerBase.html">XalanXMLSerializerBase</a>
00056 {
00057 <font class="keyword">public</font>:
00058
<a name="l00059"></a><a class="code" href="classFormatterToXMLUnicode.html#s0">00059</a> <font class="keyword">typedef</font> <font class="keyword">typename</font> UnicodeWriter::value_type value_type;
00060
00061 <font class="keyword">enum</font>
00062 {
00063 eDefaultIndentAmount = 0
00064 };
00065
<a name="l00082"></a><a class="code" href="classFormatterToXMLUnicode.html#a0">00082</a> <a class="code" href="classFormatterToXMLUnicode.html#a0">FormatterToXMLUnicode</a>(
00083 MemoryManager&amp; theManager,
00084 <a class="code" href="classWriter.html">Writer</a>&amp; writer,
00085 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; encoding,
00086 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; doctypeSystem = s_emptyString,
00087 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; doctypePublic = s_emptyString,
00088 <font class="keywordtype">bool</font> xmlDecl = <font class="keyword">true</font>,
00089 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; standalone = s_emptyString,
00090 size_type indent = eDefaultIndentAmount) :
00091 <a class="code" href="classXalanXMLSerializerBase.html">XalanXMLSerializerBase</a>(
00092 theManager,
00093 XMLVersion,
00094 encoding,
00095 doctypeSystem,
00096 doctypePublic,
00097 xmlDecl,
00098 standalone),
00099 m_stringBuffer(theManager),
00100 m_writer(writer, theManager),
00101 m_constants(),
00102 m_charPredicate(),
00103 m_indentHandler(m_writer , indent)
00104 {
00105 }
00106
00107 <font class="keyword">static</font> <a class="code" href="classFormatterToXMLUnicode.html">FormatterToXMLUnicode</a>*
<a name="l00108"></a><a class="code" href="classFormatterToXMLUnicode.html#d0">00108</a> <a class="code" href="classFormatterToXMLUnicode.html#d0">create</a>(
00109 MemoryManagerType&amp; theManager,
00110 <a class="code" href="classWriter.html">Writer</a>&amp; writer,
00111 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; encoding,
00112 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; doctypeSystem = s_emptyString,
00113 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; doctypePublic = s_emptyString,
00114 <font class="keywordtype">bool</font> xmlDecl = <font class="keyword">true</font>,
00115 <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp; standalone = s_emptyString,
00116 size_type indent = eDefaultIndentAmount)<font class="keyword"></font>
00117 <font class="keyword"> </font>{
00118
00119 <font class="keyword">typedef</font> <a class="code" href="classFormatterToXMLUnicode.html">FormatterToXMLUnicode</a> <a class="code" href="classXalanDeque.html">ThisType</a>;
00120
00121 XalanMemMgrAutoPtr&lt;ThisType, false&gt; theGuard( theManager , (<a class="code" href="classXalanDeque.html">ThisType</a>*)theManager.allocate(<font class="keyword">sizeof</font>(<a class="code" href="classXalanDeque.html">ThisType</a>)));
00122
00123 <a class="code" href="classXalanDeque.html">ThisType</a>* theResult = theGuard.get();
00124
00125 <font class="keyword">new</font> (theResult) ThisType(
00126 theManager,
00127 writer,
00128 encoding,
00129 doctypeSystem,
00130 doctypePublic,
00131 xmlDecl,
00132 standalone,
00133 indent);
00134
00135 theGuard.release();
00136
00137 <font class="keywordflow">return</font> theResult;
00138 }
00139
00140 <font class="keyword">virtual</font>
<a name="l00141"></a><a class="code" href="classFormatterToXMLUnicode.html#a1">00141</a> <a class="code" href="classFormatterToXMLUnicode.html#a1">~FormatterToXMLUnicode</a>()<font class="keyword"></font>
00142 <font class="keyword"> </font>{
00143 }
00144
00145 <a class="code" href="classWriter.html">Writer</a>*
<a name="l00146"></a><a class="code" href="classFormatterToXMLUnicode.html#a2">00146</a> <a class="code" href="classFormatterToXMLUnicode.html#a2">getWriter</a>()<font class="keyword"> const</font>
00147 <font class="keyword"> </font>{
00148 <font class="keywordflow">return</font> m_writer.getWriter();
00149 }
00150
00151 <font class="comment">// These are inherited from XalanXMLSerializerBase...</font>
00152
00153 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00154"></a><a class="code" href="classFormatterToXMLUnicode.html#a3">00154</a> <a class="code" href="classFormatterToXMLUnicode.html#a3">endDocument</a>()<font class="keyword"></font>
00155 <font class="keyword"> </font>{
00156 m_indentHandler.setStartNewLine(<font class="keyword">true</font>);
00157
00158 m_indentHandler.indent();
00159
00160 <a class="code" href="classFormatterToXMLUnicode.html#b0">flushBuffer</a>();
00161 }
00162
00163 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00164"></a><a class="code" href="classFormatterToXMLUnicode.html#a4">00164</a> <a class="code" href="classFormatterToXMLUnicode.html#a4">startElement</a>(
00165 <font class="keyword">const</font> XMLCh* <font class="keyword">const</font> name,
00166 AttributeList&amp; attrs)<font class="keyword"></font>
00167 <font class="keyword"> </font>{
00168 generateDoctypeDecl(name);
00169
00170 <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>();
00171
00172 m_indentHandler.setPreserve(<font class="keyword">false</font>);
00173
00174 m_indentHandler.indent();
00175
00176 m_indentHandler.setStartNewLine(<font class="keyword">true</font>);
00177
00178 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charLessThanSign));
00179
00180 writeName(name);
00181
00182 <font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> nAttrs = attrs.getLength();
00183
00184 <font class="keywordflow">for</font> (<font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> i = 0; i &lt; nAttrs ; i++)
00185 {
00186 processAttribute(attrs.getName(i), attrs.getValue(i));
00187 }
00188
00189 <font class="comment">// Flag the current element as not yet having any children.</font>
00190 openElementForChildren();
00191
00192 m_indentHandler.increaseIndent();
00193
00194 m_indentHandler.setPrevText(<font class="keyword">false</font>);
00195 }
00196
00197 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00198"></a><a class="code" href="classFormatterToXMLUnicode.html#a5">00198</a> <a class="code" href="classFormatterToXMLUnicode.html#a5">endElement</a>(<font class="keyword">const</font> XMLCh* <font class="keyword">const</font> name)<font class="keyword"></font>
00199 <font class="keyword"> </font>{
00200 m_indentHandler.decreaseIndent();
00201
00202 <font class="keyword">const</font> <font class="keywordtype">bool</font> hasChildNodes = childNodesWereAdded();
00203
00204 <font class="keywordflow">if</font> (hasChildNodes == <font class="keyword">true</font>)
00205 {
00206 m_indentHandler.indent();
00207
00208 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charLessThanSign));
00209 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSolidus));
00210
00211 writeName(name);
00212 }
00213 <font class="keywordflow">else</font>
00214 {
00215 <font class="keywordflow">if</font>(m_spaceBeforeClose == <font class="keyword">true</font>)
00216 {
00217 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSpace));
00218 }
00219
00220 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSolidus));
00221 }
00222
00223 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charGreaterThanSign));
00224
00225 <font class="keywordflow">if</font> (hasChildNodes == <font class="keyword">true</font>)
00226 {
00227 m_indentHandler.pop_preserve();
00228 }
00229
00230 m_indentHandler.setPrevText(<font class="keyword">false</font>);
00231 }
00232
00233 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00234"></a><a class="code" href="classFormatterToXMLUnicode.html#a6">00234</a> <a class="code" href="classFormatterToXMLUnicode.html#a6">charactersRaw</a>(
00235 <font class="keyword">const</font> XMLCh* <font class="keyword">const</font> chars,
00236 <font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> length)<font class="keyword"></font>
00237 <font class="keyword"> </font>{
00238 <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>();
00239
00240 m_indentHandler.setPreserve(<font class="keyword">true</font>);
00241
00242 m_writer.write(chars, length);
00243 }
00244
00245
00246 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00247"></a><a class="code" href="classFormatterToXMLUnicode.html#a7">00247</a> <a class="code" href="classFormatterToXMLUnicode.html#a7">entityReference</a>(<font class="keyword">const</font> XMLCh* <font class="keyword">const</font> name)<font class="keyword"></font>
00248 <font class="keyword"> </font>{
00249 <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>();
00250
00251 m_indentHandler.indent();
00252
00253 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charAmpersand));
00254
00255 writeName(name);
00256
00257 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSemicolon));
00258 }
00259
00260 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00261"></a><a class="code" href="classFormatterToXMLUnicode.html#a8">00261</a> <a class="code" href="classFormatterToXMLUnicode.html#a8">comment</a>(<font class="keyword">const</font> XMLCh* <font class="keyword">const</font> data)<font class="keyword"></font>
00262 <font class="keyword"> </font>{
00263 <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>();
00264
00265 m_indentHandler.indent();
00266
00267 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charLessThanSign));
00268 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charExclamationMark));
00269 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charHyphenMinus));
00270 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charHyphenMinus));
00271
00272 writeNormalizedData(data, XalanDOMString::length(data));
00273
00274 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charHyphenMinus));
00275 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charHyphenMinus));
00276 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charGreaterThanSign));
00277
00278 m_indentHandler.setStartNewLine(<font class="keyword">true</font>);
00279 }
00280
00281 <font class="keyword">virtual</font> <font class="keyword">const</font> <a class="code" href="classXalanDOMString.html">XalanDOMString</a>&amp;
<a name="l00282"></a><a class="code" href="classFormatterToXMLUnicode.html#a9">00282</a> <a class="code" href="classFormatterToXMLUnicode.html#a9">getEncoding</a>()<font class="keyword"> const</font>
00283 <font class="keyword"> </font>{
00284 <font class="keywordflow">return</font> m_constants.s_encodingString;
00285 }
00286
00287 <font class="keyword">protected</font>:
00288
00289 <font class="keyword">virtual</font> <font class="keywordtype">void</font>
<a name="l00290"></a><a class="code" href="classFormatterToXMLUnicode.html#b0">00290</a> <a class="code" href="classFormatterToXMLUnicode.html#b0">flushBuffer</a>()<font class="keyword"></font>
00291 <font class="keyword"> </font>{
00292 m_writer.flushBuffer();
00293 }
00294
00295 <font class="keywordtype">void</font>
<a name="l00296"></a><a class="code" href="classFormatterToXMLUnicode.html#b1">00296</a> <a class="code" href="classFormatterToXMLUnicode.html#b1">writeXMLHeader</a>()<font class="keyword"></font>
00297 <font class="keyword"> </font>{
00298 <font class="comment">// "&lt;?xml version=\""</font>
00299 m_writer.write(
00300 m_constants.s_xmlHeaderStartString,
00301 m_constants.s_xmlHeaderStartStringLength);
00302
00303 <font class="keywordflow">if</font> (<a class="code" href="DOMStringHelper_8hpp.html#a14">length</a>(m_version) != 0)
00304 {
00305 m_writer.write(m_version);
00306 }
00307 <font class="keywordflow">else</font>
00308 {
00309 m_writer.write(
00310 m_constants.s_defaultVersionString,
00311 m_constants.s_defaultVersionStringLength);
00312 }
00313
00314 <font class="comment">// "\" encoding=\""</font>
00315 m_writer.write(
00316 m_constants.s_xmlHeaderEncodingString,
00317 m_constants.s_xmlHeaderEncodingStringLength);
00318
00319 m_writer.write(m_encoding);
00320
00321 <font class="keywordflow">if</font> (<a class="code" href="DOMStringHelper_8hpp.html#a14">length</a>(m_standalone) != 0)
00322 {
00323 m_writer.write(
00324 m_constants.s_xmlHeaderStandaloneString,
00325 m_constants.s_xmlHeaderStandaloneStringLength);
00326
00327 m_writer.write(m_standalone);
00328 }
00329
00330 m_writer.write(
00331 m_constants.s_xmlHeaderEndString,
00332 m_constants.s_xmlHeaderEndStringLength);
00333
00334 <font class="keywordflow">if</font> (getNeedToOutputDoctypeDecl() == <font class="keyword">false</font>)
00335 {
00336 m_indentHandler.outputLineSep();
00337 }
00338 }
00339
00340
00341 <font class="keywordtype">void</font>
<a name="l00342"></a><a class="code" href="classFormatterToXMLUnicode.html#b2">00342</a> <a class="code" href="classFormatterToXMLUnicode.html#b2">writeDoctypeDecl</a>(<font class="keyword">const</font> XalanDOMChar* name)<font class="keyword"></font>
00343 <font class="keyword"> </font>{
00344 <font class="comment">// "&lt;!DOCTYPE "</font>
00345 m_writer.write(
00346 m_constants.s_doctypeHeaderStartString,
00347 m_constants.s_doctypeHeaderStartStringLength);
00348
00349 m_writer.write(name);
00350
00351 <font class="keywordflow">if</font>(<a class="code" href="DOMStringHelper_8hpp.html#a14">length</a>(m_doctypePublic) != 0)
00352 {
00353 <font class="comment">// " PUBLIC \""</font>
00354 m_writer.write(
00355 m_constants.s_doctypeHeaderPublicString,
00356 m_constants.s_doctypeHeaderPublicStringLength);
00357
00358 writeName(m_doctypePublic.c_str());
00359
00360 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charQuoteMark));
00361 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSpace));
00362 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charQuoteMark));
00363 }
00364 <font class="keywordflow">else</font>
00365 {
00366 <font class="comment">// " SYSTEM \""</font>
00367 m_writer.write(
00368 m_constants.s_doctypeHeaderSystemString,
00369 m_constants.s_doctypeHeaderSystemStringLength);
00370 }
00371
00372 writeName(m_doctypeSystem.c_str());
00373
00374 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charQuoteMark));
00375 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charGreaterThanSign));
00376
00377 <a class="code" href="classFormatterToXMLUnicode.html#b6">outputNewline</a>();
00378 }
00379
00380
00381 <font class="keywordtype">void</font>
<a name="l00382"></a><a class="code" href="classFormatterToXMLUnicode.html#b3">00382</a> <a class="code" href="classFormatterToXMLUnicode.html#b3">writeProcessingInstruction</a>(
00383 <font class="keyword">const</font> XMLCh* target,
00384 <font class="keyword">const</font> XMLCh* data)<font class="keyword"></font>
00385 <font class="keyword"> </font>{
00386 <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>();
00387
00388 m_indentHandler.indent();
00389
00390 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charLessThanSign));
00391 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charQuestionMark));
00392 writeName(target);
00393
00394 <font class="keyword">const</font> XalanDOMString::size_type len = <a class="code" href="DOMStringHelper_8hpp.html#a14">length</a>(data);
00395
00396 <font class="comment">// We need to make sure there is a least one whitespace character</font>
00397 <font class="comment">// between the target and the data.</font>
00398 <font class="keywordflow">if</font> ( len &gt; 0 &amp;&amp; !<a class="code" href="DOMStringHelper_8hpp.html#a47">isXMLWhitespace</a>(data[0]))
00399 {
00400 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSpace));
00401 }
00402
00403 writeNormalizedData(data, len);
00404
00405 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charQuestionMark));
00406 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charGreaterThanSign));
00407
00408 <font class="comment">// If outside of an element, then put in a new line. This whitespace</font>
00409 <font class="comment">// is not significant.</font>
00410 <font class="keywordflow">if</font> (outsideDocumentElement() == <font class="keyword">true</font>)
00411 {
00412 <a class="code" href="classFormatterToXMLUnicode.html#b6">outputNewline</a>();
00413 }
00414 }
00415
00416 <font class="keywordtype">void</font>
<a name="l00417"></a><a class="code" href="classFormatterToXMLUnicode.html#b4">00417</a> <a class="code" href="classFormatterToXMLUnicode.html#b4">writeCharacters</a>(
00418 <font class="keyword">const</font> XMLCh* chars,
00419 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> length)<font class="keyword"></font>
00420 <font class="keyword"> </font>{
00421 assert(length != 0);
00422
00423 <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>();
00424
00425 m_indentHandler.setPreserve(<font class="keyword">true</font>);
00426
00427 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> i = 0;
00428 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> firstIndex = 0;
00429
00430 <font class="keywordflow">while</font>(i &lt; length)
00431 {
00432 <font class="keyword">const</font> XalanDOMChar ch = chars[i];
00433
00434 <font class="keywordflow">if</font>(m_charPredicate.range(ch) == <font class="keyword">true</font>)
00435 {
00436 safeWriteContent(chars + firstIndex, i - firstIndex);
00437
00438 i = <a class="code" href="classFormatterToXMLUnicode.html#b14">writeNormalizedCharBig</a>(chars, i, length);
00439
00440 ++i;
00441
00442 firstIndex = i;
00443 }
00444 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(m_charPredicate.content(ch) == <font class="keyword">false</font>)
00445 {
00446 ++i;
00447 }
00448 <font class="keywordflow">else</font>
00449 {
00450 safeWriteContent(chars + firstIndex, i - firstIndex);
00451
00452 <a class="code" href="classFormatterToXMLUnicode.html#b7">writeDefaultEscape</a>(ch);
00453
00454 ++i;
00455
00456 firstIndex = i;
00457 }
00458 }
00459
00460 safeWriteContent(chars + firstIndex, i - firstIndex);
00461
00462 m_indentHandler.setPrevText(<font class="keyword">true</font>);
00463 }
00464
00465
00466 <font class="keywordtype">void</font>
<a name="l00467"></a><a class="code" href="classFormatterToXMLUnicode.html#b5">00467</a> <a class="code" href="classFormatterToXMLUnicode.html#b5">writeCDATA</a>(
00468 <font class="keyword">const</font> XMLCh* chars,
00469 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> length)<font class="keyword"></font>
00470 <font class="keyword"> </font>{
00471 assert(length != 0);
00472
00473 <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>();
00474
00475 m_indentHandler.setPreserve(<font class="keyword">true</font>);
00476
00477 m_indentHandler.indent();
00478
00479 m_writer.write(
00480 m_constants.s_cdataOpenString,
00481 m_constants.s_cdataOpenStringLength);
00482
00483 <font class="keywordtype">bool</font> outsideCDATA = <font class="keyword">false</font>;
00484
00485 <a class="code" href="classFormatterToXMLUnicode.html#b15">writeCDATAChars</a>(chars, length, outsideCDATA);
00486
00487 <font class="keywordflow">if</font> (outsideCDATA == <font class="keyword">false</font>)
00488 {
00489 m_writer.write(
00490 m_constants.s_cdataCloseString,
00491 m_constants.s_cdataCloseStringLength);
00492 }
00493 }
00494
00498 <font class="keywordtype">void</font>
<a name="l00499"></a><a class="code" href="classFormatterToXMLUnicode.html#b6">00499</a> <a class="code" href="classFormatterToXMLUnicode.html#b6">outputNewline</a>()<font class="keyword"></font>
00500 <font class="keyword"> </font>{
00501 m_writer.outputNewline();
00502 }
00503
00507 <font class="keywordtype">void</font>
<a name="l00508"></a><a class="code" href="classFormatterToXMLUnicode.html#b7">00508</a> <a class="code" href="classFormatterToXMLUnicode.html#b7">writeDefaultEscape</a>(XalanDOMChar ch)<font class="keyword"></font>
00509 <font class="keyword"> </font>{
00510 assert(m_charPredicate.content(ch) == <font class="keyword">true</font>);
00511
00512 <font class="keywordflow">if</font>(!<a class="code" href="classFormatterToXMLUnicode.html#b9">writeDefaultEntity</a>(ch))
00513 {
00514 <font class="keywordflow">if</font> (XalanUnicode::charLF == ch)
00515 {
00516 <a class="code" href="classFormatterToXMLUnicode.html#b6">outputNewline</a>();
00517 }
00518 <font class="keywordflow">else</font>
00519 {
00520 <font class="keywordflow">if</font>(m_charPredicate.isForbidden(ch) == <font class="keyword">true</font>)
00521 {
00522 throwInvalidXMLCharacterException(
00523 ch,
00524 m_version,
00525 getMemoryManager());
00526 }
00527 <font class="keywordflow">else</font>
00528 {
00529 <a class="code" href="classFormatterToXMLUnicode.html#b13">writeNumericCharacterReference</a>(ch);
00530 }
00531 }
00532 }
00533 }
00534
00538 <font class="keywordtype">void</font>
<a name="l00539"></a><a class="code" href="classFormatterToXMLUnicode.html#b8">00539</a> <a class="code" href="classFormatterToXMLUnicode.html#b8">writeDefaultAttributeEscape</a>(XalanDOMChar ch)<font class="keyword"></font>
00540 <font class="keyword"> </font>{
00541 assert(m_charPredicate.attribute(ch) == <font class="keyword">true</font>);
00542
00543 <font class="keywordflow">if</font>(<a class="code" href="classFormatterToXMLUnicode.html#b10">writeDefaultAttributeEntity</a>(ch) == <font class="keyword">false</font>)
00544 {
00545 <font class="keywordflow">if</font>(m_charPredicate.isForbidden(ch) == <font class="keyword">true</font>)
00546 {
00547 throwInvalidXMLCharacterException(
00548 ch,
00549 m_version,
00550 getMemoryManager());
00551 }
00552 <font class="keywordflow">else</font>
00553 {
00554 <a class="code" href="classFormatterToXMLUnicode.html#b13">writeNumericCharacterReference</a>(ch);
00555 }
00556
00557 }
00558 }
00559
00564 <font class="keywordtype">bool</font>
<a name="l00565"></a><a class="code" href="classFormatterToXMLUnicode.html#b9">00565</a> <a class="code" href="classFormatterToXMLUnicode.html#b9">writeDefaultEntity</a>(XalanDOMChar ch)<font class="keyword"></font>
00566 <font class="keyword"> </font>{
00567 <font class="keywordflow">if</font> (XalanUnicode::charLessThanSign == ch)
00568 {
00569 m_writer.write(
00570 m_constants.s_lessThanEntityString,
00571 m_constants.s_lessThanEntityStringLength);
00572 }
00573 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (XalanUnicode::charGreaterThanSign == ch)
00574 {
00575 m_writer.write(
00576 m_constants.s_greaterThanEntityString,
00577 m_constants.s_greaterThanEntityStringLength);
00578 }
00579 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (XalanUnicode::charAmpersand == ch)
00580 {
00581 m_writer.write(
00582 m_constants.s_ampersandEntityString,
00583 m_constants.s_ampersandEntityStringLength);
00584 }
00585 <font class="keywordflow">else</font>
00586 {
00587 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00588 }
00589
00590 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00591 }
00592
00597 <font class="keywordtype">bool</font>
<a name="l00598"></a><a class="code" href="classFormatterToXMLUnicode.html#b10">00598</a> <a class="code" href="classFormatterToXMLUnicode.html#b10">writeDefaultAttributeEntity</a>(XalanDOMChar ch)<font class="keyword"></font>
00599 <font class="keyword"> </font>{
00600 <font class="keywordflow">if</font> (<a class="code" href="classFormatterToXMLUnicode.html#b9">writeDefaultEntity</a>(ch) == <font class="keyword">true</font>)
00601 {
00602 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00603 }
00604 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (XalanUnicode::charQuoteMark == ch)
00605 {
00606 m_writer.write(
00607 m_constants.s_quoteEntityString,
00608 m_constants.s_quoteEntityStringLength);
00609 }
00610 <font class="keywordflow">else</font>
00611 {
00612 <font class="keywordflow">return</font> <font class="keyword">false</font>;
00613 }
00614
00615 <font class="keywordflow">return</font> <font class="keyword">true</font>;
00616 }
00617
00622 <font class="keywordtype">void</font>
<a name="l00623"></a><a class="code" href="classFormatterToXMLUnicode.html#b11">00623</a> <a class="code" href="classFormatterToXMLUnicode.html#b11">writeParentTagEnd</a>()<font class="keyword"></font>
00624 <font class="keyword"> </font>{
00625 <font class="keywordflow">if</font>(markParentForChildren() == <font class="keyword">true</font>)
00626 {
00627 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charGreaterThanSign));
00628
00629 m_indentHandler.setPrevText(<font class="keyword">false</font>);
00630
00631 m_indentHandler.push_preserve();
00632 }
00633 }
00634
00641 XalanDOMString::size_type
<a name="l00642"></a><a class="code" href="classFormatterToXMLUnicode.html#b12">00642</a> <a class="code" href="classFormatterToXMLUnicode.html#b12">writeNormalizedChar</a>(
00643 XalanDOMChar ch,
00644 <font class="keyword">const</font> XalanDOMChar chars[],
00645 XalanDOMString::size_type start,
00646 XalanDOMString::size_type length)<font class="keyword"></font>
00647 <font class="keyword"> </font>{
00648 <font class="keywordflow">if</font> (XalanUnicode::charLF == ch)
00649 {
00650 <a class="code" href="classFormatterToXMLUnicode.html#b6">outputNewline</a>();
00651 }
00652 <font class="keywordflow">else</font>
00653 {
00654 <font class="keywordflow">if</font>(m_charPredicate.isCharRefForbidden(ch))
00655 {
00656 throwInvalidXMLCharacterException(
00657 ch,
00658 m_version,
00659 getMemoryManager());
00660 }
00661 <font class="keywordflow">else</font>
00662 {
00663 start = m_writer.write( chars, start, length);
00664 }
00665 }
00666
00667 <font class="keywordflow">return</font> start;
00668 }
00669
00670 <font class="keywordtype">void</font>
<a name="l00671"></a><a class="code" href="classFormatterToXMLUnicode.html#b13">00671</a> <a class="code" href="classFormatterToXMLUnicode.html#b13">writeNumericCharacterReference</a>(<font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> theNumber)<font class="keyword"></font>
00672 <font class="keyword"> </font>{
00673 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charAmpersand));
00674 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charNumberSign));
00675
00676 m_writer.write(UnsignedLongToDOMString(theNumber, m_stringBuffer));
00677 <a class="code" href="DOMStringHelper_8hpp.html#a80">clear</a>(m_stringBuffer);
00678
00679 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSemicolon));
00680 }
00681
00682 XalanDOMString::size_type
<a name="l00683"></a><a class="code" href="classFormatterToXMLUnicode.html#b14">00683</a> <a class="code" href="classFormatterToXMLUnicode.html#b14">writeNormalizedCharBig</a>(
00684 <font class="keyword">const</font> XalanDOMChar chars[],
00685 XalanDOMString::size_type start,
00686 XalanDOMString::size_type length)<font class="keyword"></font>
00687 <font class="keyword"> </font>{
00688 assert( start &lt; length);
00689
00690 <font class="keyword">const</font> XalanDOMChar ch = chars[start];
00691
00692 assert(m_charPredicate.range(ch) == <font class="keyword">true</font>);
00693
00694 <font class="keywordflow">if</font> (XMLVersion == XML_VERSION_1_1 &amp;&amp;
00695 XalanUnicode::charLSEP == ch)
00696 {
00697 <a class="code" href="classFormatterToXMLUnicode.html#b13">writeNumericCharacterReference</a>(ch);
00698 }
00699 <font class="keywordflow">else</font>
00700 {
00701 start = m_writer.write(chars, start, length);
00702 }
00703
00704 <font class="keywordflow">return</font> start;
00705 }
00706
00713 <font class="keywordtype">void</font>
<a name="l00714"></a><a class="code" href="classFormatterToXMLUnicode.html#b15">00714</a> <a class="code" href="classFormatterToXMLUnicode.html#b15">writeCDATAChars</a>(
00715 <font class="keyword">const</font> XalanDOMChar chars[],
00716 XalanDOMString::size_type length,
00717 <font class="keywordtype">bool</font>&amp; outsideCDATA)<font class="keyword"></font>
00718 <font class="keyword"> </font>{
00719 XalanDOMString::size_type i = 0;
00720
00721 <font class="keywordflow">while</font>(i &lt; length)
00722 {
00723 <font class="comment">// If "]]&gt;", which would close the CDATA appears in</font>
00724 <font class="comment">// the content, we have to put the first two characters</font>
00725 <font class="comment">// in the CDATA section, close the CDATA section, then</font>
00726 <font class="comment">// open a new one and add the last character.</font>
00727
00728 <font class="keyword">const</font> XalanDOMChar theChar = chars[i];
00729
00730 <font class="keywordflow">if</font> (theChar == XalanUnicode::charRightSquareBracket &amp;&amp;
00731 i - length &gt; 2 &amp;&amp;
00732 XalanUnicode::charRightSquareBracket == chars[i + 1] &amp;&amp;
00733 XalanUnicode::charGreaterThanSign == chars[i + 2])
00734 {
00735 <font class="keywordflow">if</font> (outsideCDATA == <font class="keyword">true</font>)
00736 {
00737 m_writer.write(
00738 m_constants.s_cdataCloseString,
00739 m_constants.s_cdataCloseStringLength);
00740 }
00741
00742 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charRightSquareBracket));
00743 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charRightSquareBracket));
00744
00745 m_writer.write(
00746 m_constants.s_cdataCloseString,
00747 m_constants.s_cdataCloseStringLength);
00748
00749 m_writer.write(
00750 m_constants.s_cdataOpenString,
00751 m_constants.s_cdataOpenStringLength);
00752
00753 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charGreaterThanSign));
00754
00755 outsideCDATA = <font class="keyword">false</font>;
00756
00757 i += 2;
00758 }
00759 <font class="keywordflow">else</font>
00760 {
00761 <font class="keywordflow">if</font> (XalanUnicode::charLF == theChar)
00762 {
00763 <a class="code" href="classFormatterToXMLUnicode.html#b6">outputNewline</a>();
00764 }
00765 <font class="keywordflow">else</font> <font class="keywordflow">if</font>(m_charPredicate.isCharRefForbidden(theChar))
00766 {
00767 throwInvalidXMLCharacterException(
00768 theChar,
00769 m_version,
00770 getMemoryManager());
00771 }
00772 <font class="keywordflow">else</font>
00773 {
00774 i = m_writer.writeCDATAChar(chars, i, length, outsideCDATA);
00775 }
00776 }
00777
00778 ++i;
00779 }
00780
00781 <font class="keywordflow">if</font>(outsideCDATA == <font class="keyword">true</font>)
00782 {
00783 m_writer.write(
00784 m_constants.s_cdataOpenString,
00785 m_constants.s_cdataOpenStringLength);
00786 }
00787 }
00788
00789
00796 <font class="keywordtype">void</font>
<a name="l00797"></a><a class="code" href="classFormatterToXMLUnicode.html#b16">00797</a> <a class="code" href="classFormatterToXMLUnicode.html#b16">writeAttrString</a>(
00798 <font class="keyword">const</font> XalanDOMChar* theString,
00799 XalanDOMString::size_type theStringLength)<font class="keyword"></font>
00800 <font class="keyword"> </font>{
00801 assert(theString != 0);
00802
00803 XalanDOMString::size_type i = 0;
00804 XalanDOMString::size_type firstIndex = 0;
00805
00806 <font class="keywordflow">while</font>(i &lt; theStringLength)
00807 {
00808 <font class="keyword">const</font> XalanDOMChar ch = theString[i];
00809
00810 <font class="keywordflow">if</font>(m_charPredicate.range(ch) == <font class="keyword">true</font>)
00811 {
00812 safeWriteContent(theString + firstIndex, i - firstIndex);
00813
00814 i = <a class="code" href="classFormatterToXMLUnicode.html#b14">writeNormalizedCharBig</a>(theString, i, theStringLength);
00815
00816 ++i;
00817
00818 firstIndex = i;
00819 }
00820 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (m_charPredicate.attribute(ch) == <font class="keyword">false</font>)
00821 {
00822 ++i;
00823 }
00824 <font class="keywordflow">else</font>
00825 {
00826 safeWriteContent(theString + firstIndex, i - firstIndex);
00827
00828 <a class="code" href="classFormatterToXMLUnicode.html#b8">writeDefaultAttributeEscape</a>(ch);
00829
00830 ++i;
00831
00832 firstIndex = i;
00833 }
00834 }
00835
00836 safeWriteContent(theString + firstIndex, i - firstIndex);
00837 }
00838
00839 <font class="keyword">private</font>:
00840
00846 <font class="keywordtype">void</font>
00847 processAttribute(
00848 <font class="keyword">const</font> XalanDOMChar* name,
00849 <font class="keyword">const</font> XalanDOMChar* value)<font class="keyword"></font>
00850 <font class="keyword"> </font>{
00851 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charSpace));
00852 writeName(name);
00853 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charEqualsSign));
00854 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charQuoteMark));
00855 <a class="code" href="classFormatterToXMLUnicode.html#b16">writeAttrString</a>(value, <a class="code" href="DOMStringHelper_8hpp.html#a14">length</a>(value));
00856 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(XalanUnicode::charQuoteMark));
00857 }
00858
00864 <font class="keywordtype">void</font>
00865 writeNormalizedData(
00866 <font class="keyword">const</font> XalanDOMChar* theData,
00867 XalanDOMString::size_type theLength)<font class="keyword"></font>
00868 <font class="keyword"> </font>{
00869 <font class="keywordflow">for</font> (XalanDOMString::size_type i = 0; i &lt; theLength; ++i)
00870 {
00871 <font class="keyword">const</font> XalanDOMChar theChar = theData[i];
00872
00873 i = <a class="code" href="classFormatterToXMLUnicode.html#b12">writeNormalizedChar</a>(theChar, theData, i, theLength);
00874 }
00875 }
00876
00877 <font class="keywordtype">void</font>
00878 safeWriteContent(
00879 <font class="keyword">const</font> XalanDOMChar* theChars,
00880 XalanDOMString::size_type theLength)<font class="keyword"></font>
00881 <font class="keyword"> </font>{
00882 <font class="keywordflow">for</font>(size_type i = 0; i &lt; theLength; ++i)
00883 {
00884 m_writer.write(<a class="code" href="classFormatterToXMLUnicode.html#s0">value_type</a>(theChars[i]));
00885 }
00886 }
00887
00888 <font class="keywordtype">void</font>
00889 writeName(<font class="keyword">const</font> XalanDOMChar* theChars)<font class="keyword"></font>
00890 <font class="keyword"> </font>{
00891 assert( theChars != 0);
00892
00893 m_writer.writeNameChar(theChars, <a class="code" href="DOMStringHelper_8hpp.html#a14">length</a>(theChars));
00894 }
00895
00896 <font class="keyword">private</font>:
00897
00898 <font class="comment">// These are not implemented.</font>
00899 <a class="code" href="classFormatterToXMLUnicode.html#a0">FormatterToXMLUnicode</a>(<font class="keyword">const</font> <a class="code" href="classFormatterToXMLUnicode.html">FormatterToXMLUnicode</a>&amp;);
00900
00901 <a class="code" href="classFormatterToXMLUnicode.html">FormatterToXMLUnicode</a>&amp;
00902 operator=(<font class="keyword">const</font> <a class="code" href="classFormatterToXMLUnicode.html">FormatterToXMLUnicode</a>&amp;);
00903
00904 <font class="keywordtype">bool</font>
00905 <a class="code" href="ElemAttributeSet_8hpp.html#a1">operator==</a>(<font class="keyword">const</font> <a class="code" href="classFormatterToXMLUnicode.html">FormatterToXMLUnicode</a>&amp;) <font class="keyword">const</font>;
00906
00907
00908 <font class="comment">// Data members...</font>
00909 <a class="code" href="classXalanDOMString.html">XalanDOMString</a> m_stringBuffer;
00910
00911 UnicodeWriter m_writer;
00912
00913 ConstantsType m_constants;
00914
00915 CharPredicate m_charPredicate;
00916
00917 IndentHandler m_indentHandler;
00918 };
00919
00920
00921
00922 XALAN_CPP_NAMESPACE_END
00923
00924
00925
00926 <font class="preprocessor">#endif // FORMATTERTOXML_UNICODE_HEADER_GUARD_1357924680</font>
</font></pre></div><p align="center"><a href="diagramnotes.html">Interpreting class diagrams</a></p>
<p><FONT color="#000000" face="arial,helvetica,sanserif" size="-1">
<i><A href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</A> and
<A href="http://www.research.att.com/sw/tools/graphviz/">GraphViz</A> are used to generate this API documentation from the Xalan-C header files.</I></FONT></p>
<TABLE border="0" cellpadding="0" cellspacing="0" width="820"><TR><TD bgcolor="#0086b2"><IMG height="1" src="../resources/dot.gif" width="1" alt="dot"></TD></TR></TABLE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="80%">
<TR>
<TD WIDTH="80%" VALIGN="TOP">
<P ALIGN="CENTER"><B>Xalan-C++ XSLT Processor Version 1.10</B><BR>
Copyright &copy; 1999-2004 The Apache Software Foundation. All Rights Reserved.</i></p>
</TD>
</TR>
<TR>
<TD WIDTH="100%">
<P ALIGN="CENTER"><IMG SRC="ApacheLogo.jpg" WIDTH="387" HEIGHT="100" ALIGN="BOTTOM" BORDER="0" ALT="Apache Logo">
</TD>
</TR>
</TABLE>