Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.11
Copyright © 1999-2012 The Apache Software Foundation.
All Rights Reserved.

Apache Logo