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 00019 #if !defined(SAX2HANDLER_1357924680) 00020 #define SAX2HANDLER_1357924680 00021 00022 #include "MsgFileOutputStream.hpp" 00023 00024 #include <xercesc/sax2/DefaultHandler.hpp> 00025 #include <xercesc/util/XMLUniDefs.hpp> 00026 00027 00028 XALAN_CPP_NAMESPACE_BEGIN 00029 00030 00031 00032 XERCES_CPP_NAMESPACE_USE 00033 00034 00035 00036 static const XMLCh s_transUnitXMLCh[] = 00037 { 00038 chLatin_t, 00039 chLatin_r, 00040 chLatin_a, 00041 chLatin_n, 00042 chLatin_s, 00043 chDash, 00044 chLatin_u, 00045 chLatin_n, 00046 chLatin_i, 00047 chLatin_t, 00048 00049 chNull 00050 }; 00051 00052 00053 static const XMLCh s_sourceXMLCh[] = 00054 { 00055 chLatin_s, 00056 chLatin_o, 00057 chLatin_u, 00058 chLatin_r, 00059 chLatin_c, 00060 chLatin_e, 00061 00062 chNull 00063 }; 00064 00065 00066 static const XMLCh s_targetXMLCh[] = 00067 { 00068 chLatin_t, 00069 chLatin_a, 00070 chLatin_r, 00071 chLatin_g, 00072 chLatin_e, 00073 chLatin_t, 00074 00075 chNull 00076 }; 00077 00078 00079 static const XMLCh s_xmlLangXMLCh[] = 00080 { 00081 chLatin_x, 00082 chLatin_m, 00083 chLatin_l, 00084 chColon, 00085 chLatin_l, 00086 chLatin_a, 00087 chLatin_n, 00088 chLatin_g, 00089 chNull 00090 }; 00091 00092 00093 00094 static const XMLCh s_idXMLCh[] = 00095 { 00096 chLatin_i, 00097 chLatin_d, 00098 chNull 00099 }; 00100 00101 static const XMLCh s_textXMLCh[] = 00102 { 00103 chLatin_T, 00104 chLatin_e, 00105 chLatin_x, 00106 chLatin_t, 00107 chNull 00108 }; 00109 00110 00111 // Common class for the all system: creates index file ( common for all localization systems) 00112 // For creation data file responsible subclasses 00113 00114 00115 class SAX2Handler : public XERCES_CPP_NAMESPACE_QUALIFIER DefaultHandler 00116 { 00117 public: 00118 // ----------------------------------------------------------------------- 00119 // Constructors 00120 // ----------------------------------------------------------------------- 00121 SAX2Handler(const char* indexFileName); 00122 virtual ~SAX2Handler(); 00123 00124 public: 00125 00126 virtual void 00127 startElement( 00128 const XMLCh* const uri, 00129 const XMLCh* const localname, 00130 const XMLCh* const qname, 00131 const Attributes& attributes); 00132 00133 virtual void 00134 startDocument(); 00135 00136 virtual void 00137 endDocument(); 00138 00139 // ----------------------------------------------------------------------- 00140 // Implementations of the SAX ErrorHandler interface 00141 // ----------------------------------------------------------------------- 00142 virtual void 00143 error(const SAXParseException& e); 00144 00145 virtual void 00146 fatalError(const SAXParseException& e); 00147 00148 virtual void 00149 warning(const SAXParseException& e); 00150 00151 void 00152 setLocale(const char* localeName); 00153 00154 const XMLCh* 00155 getLocale () const 00156 { 00157 return m_locale; 00158 } 00159 00160 protected: 00161 00162 bool 00163 translateCharToXMLByteArray( 00164 XMLByte* buffer, 00165 int iBufLen, 00166 const char* szSource) const; 00167 00168 virtual void 00169 createHeaderForDataFile() = 0; 00170 00171 virtual void 00172 createBottomForDataFile() = 0; 00173 00174 virtual void 00175 printBeginOfDataLine() = 0; 00176 00177 virtual void 00178 printEndOfDataLine() = 0; 00179 00180 virtual void 00181 printToDataFile(const char* sArrayOfStrings[]) = 0; 00182 00183 void 00184 printToIndexFile(const char* sArrayOfStrings[]); 00185 00186 void 00187 printNumbOfRecords(); 00188 00189 private: 00190 00191 void 00192 createHeaderForIndexFile(); 00193 00194 void 00195 createBottomForIndexFile(); 00196 00197 void 00198 printBeginOfIndexLine(); 00199 00200 void 00201 printEndOfIndexLine(); 00202 00203 protected: 00204 00205 int m_numberOfRecords; 00206 00207 XMLCh* m_locale; 00208 00209 bool m_startCollectingCharacters; 00210 00211 // ----------------------------------------------------------------------- 00212 // SAX2 Handler is responsible for creating index file, so keep 00213 // index file FormatTarget as private data member 00214 // ----------------------------------------------------------------------- 00215 00216 private: 00217 00218 MsgFileOutputStream m_indexOutputStream; 00219 00220 // Not implemented... 00221 SAX2Handler& 00222 operator=(const SAX2Handler&); 00223 00224 SAX2Handler(const SAX2Handler&); 00225 00226 bool 00227 operator==(const SAX2Handler&) const; 00228 }; 00229 00230 00231 00232 XALAN_CPP_NAMESPACE_END 00233 00234 00235 00236 #endif //SAX2HANDLER_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|