Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XalanTransformer.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XALANTRANSFORMER_HEADER_GUARD)
17 #define XALANTRANSFORMER_HEADER_GUARD
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
26 #include <cassert>
27 #if defined(XALAN_CLASSIC_IOSTREAMS)
28 class ostream;
29 #else
30 #include <iosfwd>
31 #endif
32 #include <algorithm>
33 
34 
35 
37 
38 
39 
41 
42 
43 
46 
47 
48 
49 XALAN_DECLARE_XERCES_CLASS(EntityResolver)
50 XALAN_DECLARE_XERCES_CLASS(ErrorHandler)
51 
52 
53 
54 XALAN_CPP_NAMESPACE_BEGIN
55 
56 
57 
58 typedef XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver EntityResolverType;
59 typedef XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler ErrorHandlerType;
60 
61 
62 
63 class Function;
65 class ProblemListener;
66 class TraceListener;
67 class XSLTInit;
70 class XalanParsedSource;
72 
73 
74 
82 {
83 
84 public:
85 
86 #if defined(XALAN_NO_STD_NAMESPACE)
87  typedef ostream StreamType;
88 #else
89  typedef std::ostream StreamType;
90 #endif
91 
92  XalanTransformer(MemoryManagerType& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
93 
94  virtual
95  ~XalanTransformer();
96 
99  {
100  return m_memoryManager;
101  }
102 
103  const MemoryManagerType&
105  {
106  return m_memoryManager;
107  }
108 
117  static void
118  initialize(MemoryManagerType& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
119 
132  static void
133  terminate();
134 
153  static void
154  ICUCleanUp();
155 
156 
157  static void
158  ICUStartUp(MemoryManagerType& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
159 
169  int
171  const XalanParsedSource& theParsedXML,
172  const XSLTInputSource& theStylesheetSource,
173  const XSLTResultTarget& theResultTarget)
174  {
175  return doTransform(theParsedXML, 0, &theStylesheetSource, theResultTarget);
176  }
177 
187  int
189  const XalanParsedSource& theParsedXML,
190  const XalanCompiledStylesheet* theCompiledStylesheet,
191  const XSLTResultTarget& theResultTarget)
192  {
193  assert(theCompiledStylesheet != 0);
194 
195  return doTransform(theParsedXML, theCompiledStylesheet, 0, theResultTarget);
196  }
197 
207  int
209  const XalanParsedSource& theParsedXML,
210  const XSLTResultTarget& theResultTarget)
211  {
212  assert(s_emptyInputSource != 0);
213 
214  return transform(theParsedXML, *s_emptyInputSource, theResultTarget);
215  }
216 
228  int
229  transform(
230  const XSLTInputSource& theInputSource,
231  const XSLTInputSource& theStylesheetSource,
232  const XSLTResultTarget& theResultTarget);
233 
244  int
246  const XSLTInputSource& theInputSource,
247  const XSLTResultTarget& theResultTarget)
248  {
249  assert(s_emptyInputSource != 0);
250 
251  return transform(
252  theInputSource,
253  *s_emptyInputSource,
254  theResultTarget);
255  }
256 
275  int
276  transform(
277  const XSLTInputSource& theInputSource,
278  const XSLTInputSource& theStylesheetSource,
279  void* theOutputHandle,
280  XalanOutputHandlerType theOutputHandler,
281  XalanFlushHandlerType theFlushHandler = 0);
282 
294  int
295  transform(
296  const XSLTInputSource& theInputSource,
297  const XalanCompiledStylesheet* theCompiledStylesheet,
298  const XSLTResultTarget& theResultTarget);
299 
318  int
319  transform(
320  const XalanParsedSource& theParsedSource,
321  const XalanCompiledStylesheet* theCompiledStylesheet,
322  void* theOutputHandle,
323  XalanOutputHandlerType theOutputHandler,
324  XalanFlushHandlerType theFlushHandler = 0);
325 
343  int
344  transform(
345  const XSLTInputSource& theInputSource,
346  void* theOutputHandle,
347  XalanOutputHandlerType theOutputHandler,
348  XalanFlushHandlerType theFlushHandler = 0);
349 
362  int
363  compileStylesheet(
364  const XSLTInputSource& theStylesheetSource,
365  const XalanCompiledStylesheet*& theCompiledStylesheet);
366 
374  int
375  destroyStylesheet(const XalanCompiledStylesheet* theStylesheet);
376 
390  int
391  parseSource(
392  const XSLTInputSource& theInputSource,
393  const XalanParsedSource*& theParsedSource,
394  bool useXercesDOM = false);
395 
402  int
403  destroyParsedSource(const XalanParsedSource* theParsedSource);
404 
415  XalanDocumentBuilder*
416  createDocumentBuilder(const XalanDOMString& theURI = XalanDOMString(XalanMemMgrs::getDummyMemMgr()));
417 
425  void
426  destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder);
427 
435  void
436  installExternalFunction(
437  const XalanDOMString& theNamespace,
438  const XalanDOMString& functionName,
439  const Function& function);
440 
448  static void
449  installExternalFunctionGlobal(
450  const XalanDOMString& theNamespace,
451  const XalanDOMString& functionName,
452  const Function& function);
453 
460  void
461  uninstallExternalFunction(
462  const XalanDOMString& theNamespace,
463  const XalanDOMString& functionName);
464 
471  static void
472  uninstallExternalFunctionGlobal(
473  const XalanDOMString& theNamespace,
474  const XalanDOMString& functionName);
475 
483  void
484  setStylesheetParam(
485  const XalanDOMString& key,
486  const XalanDOMString& expression);
487 
495  void
496  setStylesheetParam(
497  const char* key,
498  const char* expression);
499 
507  void
508  addTraceListener(TraceListener* theTraceListener)
509  {
510  m_traceListeners.push_back(theTraceListener);
511  }
512 
519  bool
520  removeTraceListener(TraceListener* theTraceListener);
521 
525  void
527  {
528  m_traceListeners.clear();
529  }
530 
537  bool
539  {
540  return m_useValidation;
541  }
542 
549  void
550  setUseValidation(bool fValue)
551  {
552  m_useValidation = fValue;
553  }
554 
560  EntityResolverType*
562  {
563  return m_entityResolver;
564  }
565 
575  void
576  setEntityResolver(EntityResolverType* theResolver)
577  {
578  m_entityResolver = theResolver;
579  }
580 
586  ErrorHandlerType*
588  {
589  return m_errorHandler;
590  }
591 
597  void
598  setErrorHandler(ErrorHandlerType* theErrorHandler)
599  {
600  m_errorHandler = theErrorHandler;
601  }
602 
609  const XalanDOMChar*
611  {
612  return m_externalSchemaLocation.empty() == true ? 0 : m_externalSchemaLocation.c_str();
613  }
614 
621  void
622  setExternalSchemaLocation(const XalanDOMChar* location)
623  {
624  assert(location != 0);
625 
626  m_externalSchemaLocation = location;
627  }
628 
635  const XalanDOMChar*
637  {
638  return m_externalNoNamespaceSchemaLocation.empty() == true ? 0 : m_externalNoNamespaceSchemaLocation.c_str();
639  }
640 
647  void
648  setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location)
649  {
650  assert(location != 0);
651 
652  m_externalNoNamespaceSchemaLocation = location;
653  }
654 
661  bool
663  {
664  return m_poolAllTextNodes;
665  }
666 
675  void
677  {
678  m_poolAllTextNodes = fPool;
679  }
680 
686  ProblemListener*
688  {
689  return m_problemListener;
690  }
691 
697  void
698  setProblemListener(ProblemListener* theProblemListener)
699  {
700  m_problemListener = theProblemListener;
701  }
702 
709  const char*
710  getLastError() const
711  {
712  assert(m_errorMessage.empty() == false);
713 
714  return &m_errorMessage[0];
715  }
716 
723  const XalanDOMString&
725  {
726  return m_outputEncoding;
727  }
728 
737  void
738  setOutputEncoding(const XalanDOMString& theEncoding)
739  {
740  m_outputEncoding = theEncoding;
741  }
742 
748  int
749  getIndent() const;
750 
756  void
757  setIndent(int indentAmount);
758 
763  {
764  eEscapeURLsDefault, // Use the value in the stylesheet
765  eEscapeURLsNo, // Don't escape URLs
766  eEscapeURLsYes // Escape URLs
767  };
768 
776  eEscapeURLs
777  getEscapeURLs() const;
778 
786  void
787  setEscapeURLs(eEscapeURLs value);
788 
794  {
795  eOmitMETATagDefault, // Use the value in the stylesheet
796  eOmitMETATagNo, // Don't omit the META tag
797  eOmitMETATagYes // Omit the META tag
798  };
799 
807  eOmitMETATag
808  getOmitMETATag() const;
809 
817  void
818  setOmitMETATag(eOmitMETATag value);
819 
828  void
829  setWarningStream(StreamType* theStream)
830  {
831  m_warningStream = theStream;
832  }
833 
839  StreamType*
841  {
842  return m_warningStream;
843  }
844 
847  typedef XALAN_STD_QUALIFIER pair<XalanDOMString*, XalanDOMString*> ParamPairType;
849  typedef XALAN_STD_QUALIFIER pair<XalanQNameByValue*, Function*> FunctionPairType;
852 
854  {
855  public:
856 
858  m_memoryManagement(theManager),
859  m_release(false)
860  {
861  }
862 
864 
865  void
866  install();
867 
868  void
870  {
871  m_release = true;
872  }
873 
874  private:
875  MemoryManagerType& m_memoryManagement;
876 
877  bool m_release;
878  };
879 
881  {
882  public:
883 
885  XalanTransformer& theTransformer,
886  const XalanParsedSource* theParsedSource) :
887  m_transformer(theTransformer),
888  m_parsedSource(theParsedSource)
889  {
890  }
891 
893  {
894  m_transformer.destroyParsedSource(m_parsedSource);
895  }
896 
897  private:
898 
899  XalanTransformer& m_transformer;
900 
901  const XalanParsedSource* const m_parsedSource;
902  };
903 
905  {
907  XalanTransformer& theTransformer,
908  const XalanCompiledStylesheet* theCompiledStylesheet) :
909  m_transformer(theTransformer),
910  m_compiledStylesheet(theCompiledStylesheet)
911  {
912  }
913 
915  {
916  m_transformer.destroyStylesheet(m_compiledStylesheet);
917  }
918 
919  private:
920 
921  XalanTransformer& m_transformer;
922 
923  const XalanCompiledStylesheet* const m_compiledStylesheet;
924  };
925 
927  {
929  XalanTransformer& theTransformer,
930  XalanDocumentBuilder* theDocumentBuilder) :
931  m_transformer(theTransformer),
932  m_documentBuilder(theDocumentBuilder)
933  {
934  }
935 
937  {
938  m_transformer.destroyDocumentBuilder(m_documentBuilder);
939  }
940 
941  private:
942 
943  XalanTransformer& m_transformer;
944 
945  XalanDocumentBuilder* const m_documentBuilder;
946  };
947  template <class T>
948 #if defined(XALAN_NO_STD_NAMESPACE)
949  struct DeleteParamPairFunctor : public unary_function<T&, void>
950 #else
951  struct DeleteParamPairFunctor : public std::unary_function<T&, void>
952 #endif
953  {
954 #if defined(XALAN_NO_STD_NAMESPACE)
955  typedef unary_function<T&, void> BaseClassType;
956 #else
957  typedef std::unary_function<T&, void> BaseClassType;
958 #endif
959 
960  typedef typename BaseClassType::result_type result_type;
961  typedef typename BaseClassType::argument_type argument_type;
962 
964  m_memoryManager(theManager)
965  {
966  }
967 
968  template<class PtrT>
969  void
970  deletePtr(PtrT* ptr)const
971  {
972  ptr->~PtrT();
973  }
974 
980  result_type
981  operator()(argument_type thePair) const
982  {
983  T& tmpPair = const_cast<T&>(thePair);
984 
985  if (tmpPair.first != 0)
986  {
987  deletePtr(tmpPair.first);
988 
989  m_memoryManager.deallocate((void*)tmpPair.first);
990  }
991 
992  if (tmpPair.second != 0)
993  {
994  deletePtr(tmpPair.second);
995 
996  m_memoryManager.deallocate((void*)tmpPair.second);
997  }
998 
999 
1000  }
1001 
1002  private:
1003 
1004  MemoryManagerType& m_memoryManager;
1005 
1006  };
1007 protected:
1008 
1009 private:
1010 
1011  void
1012  reset();
1013 
1014  class EnsureReset
1015  {
1016  public:
1017 
1018  EnsureReset(XalanTransformer& theTransformer) :
1019  m_transformer(theTransformer)
1020  {
1021  }
1022 
1023  ~EnsureReset();
1024 
1025  private:
1026 
1027  XalanTransformer& m_transformer;
1028  };
1029 
1030  friend class EnsureReset;
1031 
1032  int
1033  doTransform(
1034  const XalanParsedSource& theParsedXML,
1035  const XalanCompiledStylesheet* theCompiledStylesheet,
1036  const XSLTInputSource* theStylesheetSource,
1037  const XSLTResultTarget& theResultTarget);
1038 
1039 
1040  // Data members...
1041  MemoryManagerType& m_memoryManager;
1042 
1043  CompiledStylesheetPtrVectorType m_compiledStylesheets;
1044 
1045  ParsedSourcePtrVectorType m_parsedSources;
1046 
1047  ParamPairVectorType m_paramPairs;
1048 
1049  FunctionParamPairVectorType m_functionPairs;
1050 
1051  TraceListenerVectorType m_traceListeners;
1052 
1053  CharVectorType m_errorMessage;
1054 
1055  bool m_useValidation;
1056 
1057  EntityResolverType* m_entityResolver;
1058 
1059  ErrorHandlerType* m_errorHandler;
1060 
1061  XalanDOMString m_externalSchemaLocation;
1062 
1063  XalanDOMString m_externalNoNamespaceSchemaLocation;
1064 
1065  ProblemListener* m_problemListener;
1066 
1067  StreamType* m_warningStream;
1068 
1069  XalanDOMString m_outputEncoding;
1070 
1071  bool m_poolAllTextNodes;
1072 
1073  // This should always be the latest data member!!!
1074  StylesheetExecutionContextDefault* m_stylesheetExecutionContext;
1075 
1076  static const XSLTInputSource* s_emptyInputSource;
1077 
1078  static const XSLTInit* s_xsltInit;
1079 };
1080 
1081 
1082 
1083 XALAN_CPP_NAMESPACE_END
1084 
1085 
1086 
1087 #endif // XALANTRANSFORMER_HEADER_GUARD

Interpreting class diagrams

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

dot

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

Apache Logo