fintp_base
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XSLTFilter.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef XSLTFILTER_H
22 #define XSLTFILTER_H
23 
24 #ifdef WIN32
25  #define __MSXML_LIBRARY_DEFINED__
26 #endif
27 
28 #include "../AbstractFilter.h"
29 #include "XmlUtil.h"
30 #include "../XPathHelper.h"
31 
32 #include <xalanc/XalanTransformer/XercesDOMWrapperParsedSource.hpp>
33 #include <xalanc/XalanTransformer/XalanTransformer.hpp>
34 
35 namespace FinTP
36 {
38  {
39  #if defined( TESTDLL_EXPORT ) || defined ( TESTDLL_IMPORT )
40  friend class XSLTFilterTest;
41  #endif
42 
43  public:
44 
45  static const string XSLTFILE; // XSLT File Name, from Properties (.config file, XSLT filter parameter )
46  static const string XSLTPARAM; // XSLT Parameters, from TransportHeaders
47  static const string XSLTUSEEXT;
48  static const string XSLTOUTPUTFORMAT;
49  static const string XSLTCRTPARSESOURCE; // Create a parsed source( the document will be reused )
50 
51  static const string OUTPUT_METHOD_TEXT;
52  static const string OUTPUT_METHOD_XML;
53  static const string OUTPUT_METHOD_NONE;
54 
55  XSLTFilter();
56  ~XSLTFilter();
57 
58  // return true if the filter supports logging payload to a file
59  // note for overrides : return true/false if the payload can be read without rewinding ( not a stream )
60  bool canLogPayload();
61  // return true if the filter can execute the requested operation in client/server context
62  bool isMethodSupported( FilterMethod method, bool asClient );
63 
64  FilterResult ProcessMessage( XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* inputOutputData, NameValueCollection& transportHeaders, bool asClient );
65  FilterResult ProcessMessage( const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* inputData, AbstractFilter::buffer_type outputData, NameValueCollection& transportHeaders, bool asClient );
66 
67  FilterResult ProcessMessage( AbstractFilter::buffer_type inputData, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* outputData, NameValueCollection& transportHeaders, bool asClient )
68  {
70  }
71  FilterResult ProcessMessage( AbstractFilter::buffer_type inputData, AbstractFilter::buffer_type outputData, NameValueCollection& transportHeaders, bool asClient );
72 
73  FilterResult ProcessMessage( AbstractFilter::buffer_type inputData, unsigned char** outputData, NameValueCollection& transportHeaders, bool asClient )
74  {
76  }
77 
78  //custom overloads
79  FilterResult ProcessMessage( const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* inputData, unsigned char** outputData, NameValueCollection& transportHeaders, bool asClient );
80  FilterResult ProcessMessage( XALAN_CPP_NAMESPACE_QUALIFIER XercesDOMWrapperParsedSource* inputData, AbstractFilter::buffer_type outputData, NameValueCollection& transportHeaders, bool asClient );
81 
82  // custom methods
83  static XALAN_CPP_NAMESPACE_QUALIFIER XercesDOMWrapperParsedSource* parseSource( const XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* inputData );
84  static void releaseSource( XALAN_CPP_NAMESPACE_QUALIFIER XercesDOMWrapperParsedSource* source );
85 
86  private:
87 
88  string getTransform( NameValueCollection& headers );
89  void replyOutputFormat( NameValueCollection& headers, int format ) const;
90 
91  // returns a thread-static transformer
92  static XALAN_CPP_NAMESPACE_QUALIFIER XalanTransformer* getTransformer();
93 
94  // returns a thread-static transformer
95  //static XALAN_CPP_NAMESPACE_QUALIFIER XalanTransformer* getErrorReporter();
96 
97  // returns a thread-static compiled XSLT from the cache, or compiles/inserts in cache/returns the compiled XSLT
98  static const XALAN_CPP_NAMESPACE_QUALIFIER XalanCompiledStylesheet* getXSLT( const string& filename );
99 
100  //static XALAN_CPP_NAMESPACE_QUALIFIER XalanDOMString m_ExtNamespace;
101 
102  static pthread_once_t KeysCreate;
103  static pthread_key_t TransformerKey;
104  static pthread_key_t CompiledXSLTsKey;
105 
106  static void CreateKeys();
107  static void DeleteTransformers( void* data );
108  //static void DeleteCompiledXSLTs( void* data );
109 
110  static XALAN_CPP_NAMESPACE_QUALIFIER XercesParserLiaison* m_Liaison;
111  static XALAN_CPP_NAMESPACE_QUALIFIER XercesDOMSupport* m_DOMSupport;
112  };
113 }
114 
115 #endif