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(XALAN_FILEUTILITY_HEADER_GUARD_1357924680) 00019 #define XALAN_FILEUTILITY_HEADER_GUARD_1357924680 00020 00021 00022 00023 #include "xalanc/Harness/XalanHarnessDefinitions.hpp" 00024 00025 00026 #include "xalanc/Include/XalanVector.hpp" 00027 00028 00029 #if defined(XALAN_CLASSIC_IOSTREAMS) 00030 #include <strstream.h> 00031 #else 00032 #include <strstream> 00033 #endif 00034 00035 00036 00037 #include "xalanc/XalanDOM/XalanDOMString.hpp" 00038 00039 00040 00041 XALAN_CPP_NAMESPACE_BEGIN 00042 00043 00044 00045 class FormatterListener; 00046 class PrintWriter; 00047 class StylesheetRoot; 00048 class XalanCompiledStylesheet; 00049 class XalanDocument; 00050 class XalanNode; 00051 class XalanSourceTreeDocument; 00052 class XalanTransformer; 00053 class XalanXMLFileReporter; 00054 class XSLTInputSource; 00055 00056 00057 XALAN_USING_XERCES(MemoryManager) 00058 00059 00060 00061 // This class is exported from the Harness.dll 00062 class XALAN_HARNESS_EXPORT XalanFileUtility 00063 { 00064 public: 00065 00066 // A vector to hold directory names and file names. 00067 00068 typedef XalanVector<XalanDOMString> FileNameVectorType; 00069 typedef XalanVector<char> CharVectorType; 00070 00071 struct XALAN_HARNESS_EXPORT reportStruct 00072 { 00073 XalanDOMString theDrive; 00074 XalanDOMString testOrFile; 00075 XalanDOMString xmlFileURL; 00076 XalanDOMString xslFileURL; 00077 XalanDOMString xmlFormat; 00078 const char* msg; 00079 XalanDOMString currentNode; 00080 XalanDOMString actual; 00081 XalanDOMString expected; 00082 int pass; 00083 int fail; 00084 int nogold; 00085 00086 reportStruct(MemoryManager& theManager); 00087 00088 void 00089 reset(); 00090 private: 00091 //Not implemented 00092 reportStruct(); 00093 reportStruct(const reportStruct&); 00094 00095 } data; 00096 00097 struct XALAN_HARNESS_EXPORT cmdParams 00098 { 00099 private: 00100 00101 #if defined(XALAN_NO_STD_NAMESPACE) 00102 typedef ostrstream StreamType; 00103 #else 00104 typedef std::ostrstream StreamType; 00105 #endif 00106 00107 StreamType help; 00108 00109 public: 00110 00111 XalanDOMString base; 00112 XalanDOMString output; 00113 XalanDOMString gold; 00114 XalanDOMString sub; 00115 int source; 00116 bool skip; 00117 long iters; 00118 00119 00120 cmdParams(MemoryManager& theManager); 00121 00122 ~cmdParams() 00123 { 00124 } 00125 00126 const char* 00127 getHelpMessage(); 00128 00129 StreamType& 00130 getHelpStream() 00131 { 00132 return help; 00133 } 00134 private: 00135 //Not implemented 00136 cmdParams(); 00137 cmdParams(const cmdParams&); 00138 00139 } args; 00140 00141 /** Simple constructor, does not perform initialization. */ 00142 XalanFileUtility(MemoryManager& theManager); 00143 00144 ~XalanFileUtility(); 00145 00146 bool 00147 getVerbose() const 00148 { 00149 return m_verbose; 00150 } 00151 00152 void 00153 setVerbose(bool flag) 00154 { 00155 m_verbose = flag; 00156 } 00157 00158 int 00159 getFailureCount() const 00160 { 00161 return data.fail; 00162 } 00163 00164 /** 00165 * Utility method used to get test files from a specific directory. 00166 * @returns a vector containing test files. 00167 */ 00168 00169 XalanDOMString& 00170 getDrive(XalanDOMString& theResult); 00171 00172 bool 00173 getParams( 00174 int argc, 00175 char* argv[], 00176 const char* outDir, 00177 bool fsetGold = true); 00178 00179 00180 FileNameVectorType& 00181 getTestFileNames( 00182 const XalanDOMString& baseDir, 00183 const XalanDOMString& relDir, 00184 bool useDirPrefix, 00185 FileNameVectorType& theFiles); 00186 00187 /** 00188 * Utility method used to get subdirectories from a specific directory. 00189 * @returns a vector containing directory files. 00190 */ 00191 FileNameVectorType& 00192 getDirectoryNames(const XalanDOMString& rootDirectory, 00193 FileNameVectorType& theFiles); 00194 00195 /** 00196 * Utility method used to create default directories when neccessary 00197 */ 00198 void 00199 checkAndCreateDir(const XalanDOMString& directory); 00200 00201 /** 00202 * Utility method determines if directory exists. 00203 */ 00204 bool 00205 checkDir(const XalanDOMString& directory); 00206 00207 /** 00208 * Utility method used to get XSL file based on XML file. 00209 * @returns a XalanDOMString. 00210 */ 00211 XalanDOMString& 00212 getXSLFileName(const XalanDOMString& theXMLFileName, 00213 XalanDOMString& theResult); 00214 00215 /** 00216 * Utility method used to get OUT file based on XML file. 00217 * @returns a XalanDOMString. 00218 */ 00219 XalanDOMString& 00220 generateFileName( 00221 const XalanDOMString& theXMLFileName, 00222 const char* suffix, 00223 XalanDOMString& theResult, 00224 bool* status = 0); 00225 00226 /** 00227 * Utility method used to generate UniqRunid. 00228 * @returns a XalanDOMString. 00229 */ 00230 XalanDOMString& 00231 generateUniqRunid(XalanDOMString& theResult); 00232 00233 /** 00234 * Utility methods used to get Xerces Version number. 00235 * @returns a XalanDOMString. 00236 */ 00237 XalanDOMString& 00238 getXercesVersion(XalanDOMString& theResult); 00239 00240 void 00241 checkResults( 00242 const XalanDOMString& outputFile, 00243 const XalanDOMString& goldFile, 00244 XalanXMLFileReporter& logfile); 00245 00246 void 00247 checkAPIResults( 00248 const XalanDOMString& actual, 00249 const XalanDOMString& expected, 00250 const char* msg, 00251 XalanXMLFileReporter& logfile, 00252 const XalanDOMString& outputFile, 00253 const XalanDOMString& goldFile, 00254 bool containsOnly = false); 00255 00256 // This API is deprecated. Please use the following 00257 // one. 00258 void 00259 checkAPIResults( 00260 const char* actual, 00261 const char* expected, 00262 const char* msg, 00263 XalanXMLFileReporter& logfile, 00264 const XalanDOMString& outputFile, 00265 const XalanDOMString& goldFile, 00266 MemoryManager& /* theManager */, 00267 bool containsOnly = false) 00268 { 00269 checkAPIResults( 00270 actual, 00271 expected, 00272 msg, 00273 logfile, 00274 outputFile, 00275 goldFile, 00276 containsOnly); 00277 } 00278 00279 void 00280 checkAPIResults( 00281 const char* actual, 00282 const char* expected, 00283 const char* msg, 00284 XalanXMLFileReporter& logfile, 00285 const XalanDOMString& outputFile, 00286 const XalanDOMString& goldFile, 00287 bool containsOnly = false) 00288 { 00289 checkAPIResults( 00290 XalanDOMString(actual, getMemoryManager()), 00291 XalanDOMString(expected, getMemoryManager()), 00292 msg, 00293 logfile, 00294 outputFile, 00295 goldFile, 00296 containsOnly); 00297 } 00298 00299 /** 00300 * Utility method used to compare the results. It inturn 00301 * call domCompare. 00302 * @returns Void. 00303 */ 00304 void 00305 checkDOMResults( 00306 const XalanDOMString& theOutputFile, 00307 const XalanCompiledStylesheet* compiledSS, 00308 const XalanSourceTreeDocument* dom, 00309 const XSLTInputSource& goldInputSource, 00310 XalanXMLFileReporter& logfile); 00311 00312 bool 00313 compareSerializedResults( 00314 const XalanDOMString& transformResult, 00315 const XalanDOMString& goldInputSource); 00316 00317 /** 00318 * Utility method used to create a FormatterToXML FormatterListener. 00319 * This is required to DOM comparisions. 00320 * @returns a pointer to a FormatterListener. 00321 */ 00322 FormatterListener* 00323 getXMLFormatter( 00324 PrintWriter& resultWriter, 00325 int indentAmount, 00326 const XalanDOMString& mimeEncoding, 00327 const StylesheetRoot* stylesheet); 00328 00329 00330 bool 00331 fileCompare( 00332 const char* goldFile, 00333 const char* outputFile); 00334 00335 /** 00336 * Utility methods used to perform a DOM Compare 00337 * @returns boolean 00338 */ 00339 bool 00340 domCompare(const XalanNode& gold, const XalanNode& doc); 00341 00342 /** 00343 * Utility methods used to perform a DOM Compare 00344 * @returns boolean 00345 */ 00346 bool 00347 domCompare( 00348 const XalanDocument& gold, 00349 const XalanDocument& doc); 00350 00351 /** 00352 * Utility methods used to diff two Element nodes. 00353 * @returns boolean. 00354 */ 00355 bool 00356 diffElement(const XalanNode& gold, const XalanNode& doc); 00357 00358 /** 00359 * Utility methods used to diff two nodes. 00360 * @returns true if the nodes are equal, and false if not. 00361 */ 00362 bool 00363 diffNode( 00364 const XalanNode& gold, 00365 const XalanNode& doc); 00366 00367 /** 00368 * Utility methods used to diff two nodes. 00369 * @returns true if the nodes are equal, and false if not. 00370 */ 00371 bool 00372 diffNode( 00373 const XalanNode* gold, 00374 const XalanNode* doc); 00375 00376 /** 00377 * Utility methods used to diff two Element nodes. 00378 * @returns boolean. 00379 */ 00380 bool 00381 diffElement2( 00382 const XalanNode& gold, 00383 const XalanNode& doc); 00384 00385 /** 00386 * Utility methods used to diff two attribute nodes. 00387 * @returns boolean. 00388 */ 00389 bool 00390 diffAttr(const XalanNode* gAttr, const XalanNode* dAttr); 00391 00392 /** 00393 * Utility methods used to report Pass/Fail numbers. 00394 * @returns void. 00395 */ 00396 void 00397 reportPassFail(XalanXMLFileReporter& logfile); 00398 00399 void 00400 reportPassFail(XalanXMLFileReporter& logfile, const XalanDOMString& runid); 00401 00402 void 00403 analyzeResults(XalanTransformer& xalan, const XalanDOMString& resultsFile); 00404 00405 static const XalanDOMChar s_xmlSuffix[]; 00406 00407 static const XalanDOMChar s_pathSep[]; 00408 00409 const MemoryManager& 00410 getMemoryManager() const 00411 { 00412 return m_buffer.getMemoryManager(); 00413 } 00414 00415 MemoryManager& 00416 getMemoryManager() 00417 { 00418 return m_buffer.getMemoryManager(); 00419 } 00420 00421 private: 00422 00423 static const XalanDOMString s_emptyString; 00424 00425 XalanDOMString& 00426 getProgramName(const char* fullName, XalanDOMString& theBuffer); 00427 00428 /** 00429 * Utility methods used to collect information about compare failures. 00430 * @returns void. 00431 */ 00432 void 00433 collectData( 00434 const char* errmsg, 00435 const XalanDOMString& currentnode, 00436 const XalanDOMString& actdata, 00437 const XalanDOMString& expdata); 00438 00439 /** 00440 * Utility methods used to report DOM compare errors. 00441 * @returns void. 00442 */ 00443 void 00444 reportError(); 00445 00446 void 00447 debugNodeData(const XalanDOMString& /* value */); 00448 00449 void 00450 debugNodeData( 00451 const XalanDOMString& /* node */, 00452 const XalanDOMString& /* value */); 00453 00454 void 00455 debugAttributeData(const XalanDOMString& /* value */); 00456 00457 private: 00458 00459 CharVectorType m_buffer; 00460 00461 bool m_verbose; 00462 00463 //Not implemented 00464 XalanFileUtility(); 00465 XalanFileUtility(const XalanFileUtility&); 00466 }; 00467 00468 00469 00470 XALAN_CPP_NAMESPACE_END 00471 00472 00473 00474 #endif // XALAN_FILEUTILITY_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 |
|