Xalan-C++ API Reference  1.12.0
XalanFileUtility.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(XALAN_FILEUTILITY_HEADER_GUARD_1357924680)
19 #define XALAN_FILEUTILITY_HEADER_GUARD_1357924680
20 
21 
22 
24 
25 
27 
28 
29 #include <strstream>
30 
31 
32 
34 
35 
36 
37 namespace XALAN_CPP_NAMESPACE {
38 
39 
40 
41 class FormatterListener;
42 class PrintWriter;
43 class StylesheetRoot;
44 class XalanCompiledStylesheet;
45 class XalanDocument;
46 class XalanNode;
47 class XalanSourceTreeDocument;
48 class XalanTransformer;
49 class XalanXMLFileReporter;
50 class XSLTInputSource;
51 
52 
53 using xercesc::MemoryManager;
54 
55 
56 
57 // This class is exported from the Harness.dll
59 {
60 public:
61 
62 // A vector to hold directory names and file names.
63 
66 
68  {
74  const char* msg;
78  int pass;
79  int fail;
80  int nogold;
81 
82  reportStruct(MemoryManager& theManager);
83 
84  void
85  reset();
86  private:
87  //Not implemented
88  reportStruct();
89  reportStruct(const reportStruct&);
90 
91  } data;
92 
94  {
95  private:
96 
97  typedef std::ostrstream StreamType;
98 
99  StreamType help;
100 
101  public:
102 
107  int source;
108  bool skip;
109  long iters;
110 
111 
112  cmdParams(MemoryManager& theManager);
113 
115  {
116  }
117 
118  const char*
120 
121  StreamType&
123  {
124  return help;
125  }
126  private:
127  //Not implemented
128  cmdParams();
129  cmdParams(const cmdParams&);
130 
131  } args;
132 
133  /** Simple constructor, does not perform initialization. */
134  XalanFileUtility(MemoryManager& theManager);
135 
137 
138  bool
139  getVerbose() const
140  {
141  return m_verbose;
142  }
143 
144  void
145  setVerbose(bool flag)
146  {
147  m_verbose = flag;
148  }
149 
150  int
152  {
153  return data.fail;
154  }
155 
156  /**
157  * Utility method used to get test files from a specific directory.
158  * @returns a vector containing test files.
159  */
160 
163 
164  bool
166  int argc,
167  char* argv[],
168  const char* outDir,
169  bool fsetGold = true);
170 
171 
174  const XalanDOMString& baseDir,
175  const XalanDOMString& relDir,
176  bool useDirPrefix,
177  FileNameVectorType& theFiles);
178 
179  /**
180  * Utility method used to get subdirectories from a specific directory.
181  * @returns a vector containing directory files.
182  */
184  getDirectoryNames(const XalanDOMString& rootDirectory,
185  FileNameVectorType& theFiles);
186 
187  /**
188  * Utility method used to create default directories when neccessary
189  */
190  void
192 
193  /**
194  * Utility method determines if directory exists.
195  */
196  bool
197  checkDir(const XalanDOMString& directory);
198 
199  /**
200  * Utility method used to get XSL file based on XML file.
201  * @returns a XalanDOMString.
202  */
204  getXSLFileName(const XalanDOMString& theXMLFileName,
205  XalanDOMString& theResult);
206 
207  /**
208  * Utility method used to get OUT file based on XML file.
209  * @returns a XalanDOMString.
210  */
213  const XalanDOMString& theXMLFileName,
214  const char* suffix,
215  XalanDOMString& theResult,
216  bool* status = 0);
217 
218  /**
219  * Utility method used to generate UniqRunid.
220  * @returns a XalanDOMString.
221  */
224 
225  /**
226  * Utility methods used to get Xerces Version number.
227  * @returns a XalanDOMString.
228  */
231 
232  void
234  const XalanDOMString& outputFile,
235  const XalanDOMString& goldFile,
236  XalanXMLFileReporter& logfile);
237 
238  void
240  const XalanDOMString& actual,
241  const XalanDOMString& expected,
242  const char* msg,
243  XalanXMLFileReporter& logfile,
244  const XalanDOMString& outputFile,
245  const XalanDOMString& goldFile,
246  bool containsOnly = false);
247 
248  // This API is deprecated. Please use the following
249  // one.
250  void
252  const char* actual,
253  const char* expected,
254  const char* msg,
255  XalanXMLFileReporter& logfile,
256  const XalanDOMString& outputFile,
257  const XalanDOMString& goldFile,
258  MemoryManager& /* theManager */,
259  bool containsOnly = false)
260  {
261  checkAPIResults(
262  actual,
263  expected,
264  msg,
265  logfile,
266  outputFile,
267  goldFile,
268  containsOnly);
269  }
270 
271  void
273  const char* actual,
274  const char* expected,
275  const char* msg,
276  XalanXMLFileReporter& logfile,
277  const XalanDOMString& outputFile,
278  const XalanDOMString& goldFile,
279  bool containsOnly = false)
280  {
281  checkAPIResults(
282  XalanDOMString(actual, getMemoryManager()),
283  XalanDOMString(expected, getMemoryManager()),
284  msg,
285  logfile,
286  outputFile,
287  goldFile,
288  containsOnly);
289  }
290 
291  /**
292  * Utility method used to compare the results. It inturn
293  * call domCompare.
294  * @returns Void.
295  */
296  void
298  const XalanDOMString& theOutputFile,
299  const XalanCompiledStylesheet* compiledSS,
300  const XalanSourceTreeDocument* dom,
301  const XSLTInputSource& goldInputSource,
302  XalanXMLFileReporter& logfile);
303 
304  bool
306  const XalanDOMString& transformResult,
307  const XalanDOMString& goldInputSource);
308 
309  /**
310  * Utility method used to create a FormatterToXML FormatterListener.
311  * This is required to DOM comparisions.
312  * @returns a pointer to a FormatterListener.
313  */
316  PrintWriter& resultWriter,
317  int indentAmount,
318  const XalanDOMString& mimeEncoding,
319  const StylesheetRoot* stylesheet);
320 
321 
322  bool
324  const char* goldFile,
325  const char* outputFile);
326 
327  /**
328  * Utility methods used to perform a DOM Compare
329  * @returns boolean
330  */
331  bool
332  domCompare(const XalanNode& gold, const XalanNode& doc);
333 
334  /**
335  * Utility methods used to perform a DOM Compare
336  * @returns boolean
337  */
338  bool
340  const XalanDocument& gold,
341  const XalanDocument& doc);
342 
343  /**
344  * Utility methods used to diff two Element nodes.
345  * @returns boolean.
346  */
347  bool
348  diffElement(const XalanNode& gold, const XalanNode& doc);
349 
350  /**
351  * Utility methods used to diff two nodes.
352  * @returns true if the nodes are equal, and false if not.
353  */
354  bool
356  const XalanNode& gold,
357  const XalanNode& doc);
358 
359  /**
360  * Utility methods used to diff two nodes.
361  * @returns true if the nodes are equal, and false if not.
362  */
363  bool
365  const XalanNode* gold,
366  const XalanNode* doc);
367 
368  /**
369  * Utility methods used to diff two Element nodes.
370  * @returns boolean.
371  */
372  bool
374  const XalanNode& gold,
375  const XalanNode& doc);
376 
377  /**
378  * Utility methods used to diff two attribute nodes.
379  * @returns boolean.
380  */
381  bool
382  diffAttr(const XalanNode* gAttr, const XalanNode* dAttr);
383 
384  /**
385  * Utility methods used to report Pass/Fail numbers.
386  * @returns void.
387  */
388  void
390 
391  void
393 
394  void
395  analyzeResults(XalanTransformer& xalan, const XalanDOMString& resultsFile);
396 
397  static const XalanDOMChar s_xmlSuffix[];
398 
399  static const XalanDOMChar s_pathSep[];
400 
401  const MemoryManager&
403  {
404  return m_buffer.getMemoryManager();
405  }
406 
407  MemoryManager&
409  {
410  return m_buffer.getMemoryManager();
411  }
412 
413 private:
414 
415  static const XalanDOMString s_emptyString;
416 
418  getProgramName(const char* fullName, XalanDOMString& theBuffer);
419 
420  /**
421  * Utility methods used to collect information about compare failures.
422  * @returns void.
423  */
424  void
425  collectData(
426  const char* errmsg,
427  const XalanDOMString& currentnode,
428  const XalanDOMString& actdata,
429  const XalanDOMString& expdata);
430 
431  /**
432  * Utility methods used to report DOM compare errors.
433  * @returns void.
434  */
435  void
436  reportError();
437 
438  void
439  debugNodeData(const XalanDOMString& /* value */);
440 
441  void
442  debugNodeData(
443  const XalanDOMString& /* node */,
444  const XalanDOMString& /* value */);
445 
446  void
447  debugAttributeData(const XalanDOMString& /* value */);
448 
449 private:
450 
451  CharVectorType m_buffer;
452 
453  bool m_verbose;
454 
455  //Not implemented
458 };
459 
460 
461 
462 }
463 
464 
465 
466 #endif // XALAN_FILEUTILITY_HEADER_GUARD_1357924680
#define XALAN_HARNESS_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
A SAX-based formatter interface for the XSL processor.
This acts as the stylesheet root of the stylesheet tree, and holds values that are shared by all styl...
This is an abstraction of the StylesheetRoot class.
bool diffElement2(const XalanNode &gold, const XalanNode &doc)
Utility methods used to diff two Element nodes.
bool fileCompare(const char *goldFile, const char *outputFile)
bool getParams(int argc, char *argv[], const char *outDir, bool fsetGold=true)
void checkDOMResults(const XalanDOMString &theOutputFile, const XalanCompiledStylesheet *compiledSS, const XalanSourceTreeDocument *dom, const XSLTInputSource &goldInputSource, XalanXMLFileReporter &logfile)
Utility method used to compare the results.
void reportPassFail(XalanXMLFileReporter &logfile)
Utility methods used to report Pass/Fail numbers.
XalanVector< char > CharVectorType
void checkAndCreateDir(const XalanDOMString &directory)
Utility method used to create default directories when neccessary.
bool checkDir(const XalanDOMString &directory)
Utility method determines if directory exists.
void checkAPIResults(const char *actual, const char *expected, const char *msg, XalanXMLFileReporter &logfile, const XalanDOMString &outputFile, const XalanDOMString &goldFile, bool containsOnly=false)
XalanDOMString & getXSLFileName(const XalanDOMString &theXMLFileName, XalanDOMString &theResult)
Utility method used to get XSL file based on XML file.
bool diffNode(const XalanNode *gold, const XalanNode *doc)
Utility methods used to diff two nodes.
void checkAPIResults(const XalanDOMString &actual, const XalanDOMString &expected, const char *msg, XalanXMLFileReporter &logfile, const XalanDOMString &outputFile, const XalanDOMString &goldFile, bool containsOnly=false)
bool domCompare(const XalanNode &gold, const XalanNode &doc)
Utility methods used to perform a DOM Compare.
bool diffNode(const XalanNode &gold, const XalanNode &doc)
Utility methods used to diff two nodes.
const MemoryManager & getMemoryManager() const
FormatterListener * getXMLFormatter(PrintWriter &resultWriter, int indentAmount, const XalanDOMString &mimeEncoding, const StylesheetRoot *stylesheet)
Utility method used to create a FormatterToXML FormatterListener.
void reportPassFail(XalanXMLFileReporter &logfile, const XalanDOMString &runid)
XalanDOMString & generateFileName(const XalanDOMString &theXMLFileName, const char *suffix, XalanDOMString &theResult, bool *status=0)
Utility method used to get OUT file based on XML file.
bool diffElement(const XalanNode &gold, const XalanNode &doc)
Utility methods used to diff two Element nodes.
FileNameVectorType & getDirectoryNames(const XalanDOMString &rootDirectory, FileNameVectorType &theFiles)
Utility method used to get subdirectories from a specific directory.
bool compareSerializedResults(const XalanDOMString &transformResult, const XalanDOMString &goldInputSource)
bool domCompare(const XalanDocument &gold, const XalanDocument &doc)
Utility methods used to perform a DOM Compare.
void analyzeResults(XalanTransformer &xalan, const XalanDOMString &resultsFile)
MemoryManager & getMemoryManager()
XalanVector< XalanDOMString > FileNameVectorType
bool diffAttr(const XalanNode *gAttr, const XalanNode *dAttr)
Utility methods used to diff two attribute nodes.
XalanDOMString & getDrive(XalanDOMString &theResult)
Utility method used to get test files from a specific directory.
void checkResults(const XalanDOMString &outputFile, const XalanDOMString &goldFile, XalanXMLFileReporter &logfile)
XalanFileUtility(MemoryManager &theManager)
Simple constructor, does not perform initialization.
FileNameVectorType & getTestFileNames(const XalanDOMString &baseDir, const XalanDOMString &relDir, bool useDirPrefix, FileNameVectorType &theFiles)
XalanDOMString & generateUniqRunid(XalanDOMString &theResult)
Utility method used to generate UniqRunid.
XalanDOMString & getXercesVersion(XalanDOMString &theResult)
Utility methods used to get Xerces Version number.
void checkAPIResults(const char *actual, const char *expected, const char *msg, XalanXMLFileReporter &logfile, const XalanDOMString &outputFile, const XalanDOMString &goldFile, MemoryManager &, bool containsOnly=false)
This is a simple C++ interface for some common usage patterns.
cmdParams(MemoryManager &theManager)
reportStruct(MemoryManager &theManager)