Fix errors thrown due to platform libxml2 version upgrade from 2.11.5 -> 2.12.5
[platform/framework/web/chromium-efl.git] / third_party / blink / renderer / core / xml / xslt_processor.h
1 /*
2  * This file is part of the XSL implementation.
3  *
4  * Copyright (C) 2004, 2007, 2008 Apple, Inc. All rights reserved.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22
23 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_XML_XSLT_PROCESSOR_H_
24 #define THIRD_PARTY_BLINK_RENDERER_CORE_XML_XSLT_PROCESSOR_H_
25
26 #include "third_party/blink/renderer/core/dom/node.h"
27 #include "third_party/blink/renderer/core/xml/xsl_style_sheet.h"
28 #include "third_party/blink/renderer/platform/bindings/script_wrappable.h"
29 #include "third_party/blink/renderer/platform/wtf/hash_map.h"
30 #include "third_party/blink/renderer/platform/wtf/text/string_hash.h"
31
32 #include <libxml/parserInternals.h>
33 #include <libxslt/documents.h>
34
35 namespace blink {
36
37 class LocalFrame;
38 class Document;
39 class DocumentFragment;
40
41 class XSLTProcessor final : public ScriptWrappable {
42   DEFINE_WRAPPERTYPEINFO();
43
44  public:
45   static XSLTProcessor* Create(Document& document) {
46     return MakeGarbageCollected<XSLTProcessor>(document);
47   }
48
49   XSLTProcessor(Document& document) : document_(&document) {}
50   ~XSLTProcessor() override;
51
52   void SetXSLStyleSheet(XSLStyleSheet* style_sheet) {
53     stylesheet_ = style_sheet;
54   }
55   bool TransformToString(Node* source,
56                          String& result_mime_type,
57                          String& result_string,
58                          String& result_encoding);
59   Document* CreateDocumentFromSource(const String& source,
60                                      const String& source_encoding,
61                                      const String& source_mime_type,
62                                      Node* source_node,
63                                      LocalFrame*);
64
65   // DOM methods
66   void importStylesheet(Node* style) { stylesheet_root_node_ = style; }
67   DocumentFragment* transformToFragment(Node* source, Document* ouput_doc);
68   Document* transformToDocument(Node* source);
69
70   void setParameter(const String& namespace_uri,
71                     const String& local_name,
72                     const String& value);
73   String getParameter(const String& namespace_uri,
74                       const String& local_name) const;
75   void removeParameter(const String& namespace_uri, const String& local_name);
76   void clearParameters() { parameters_.clear(); }
77
78   void reset();
79
80 #if LIBXML_VERSION >= 21205
81   static void ParseErrorFunc(void* user_data, const xmlError*);
82 #else
83   static void ParseErrorFunc(void* user_data, xmlError*);
84 #endif
85   static void GenericErrorFunc(void* user_data, const char* msg, ...);
86
87   // Only for libXSLT callbacks
88   XSLStyleSheet* XslStylesheet() const { return stylesheet_.Get(); }
89
90   typedef HashMap<String, String> ParameterMap;
91
92   void Trace(Visitor*) const override;
93
94  private:
95   Member<XSLStyleSheet> stylesheet_;
96   Member<Node> stylesheet_root_node_;
97   Member<Document> document_;
98   ParameterMap parameters_;
99 };
100
101 }  // namespace blink
102
103 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_XML_XSLT_PROCESSOR_H_