1 /* libxml2 - Library for parsing XML documents
2 * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3 *
4 * This file is not part of the GNU gettext program, but is used with
5 * GNU gettext.
6 *
7 * The original copyright notice is as follows:
8 */
9
10 /*
11 * Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this software and associated documentation files (the "Software"), to deal
15 * in the Software without restriction, including without limitation the rights
16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 * copies of the Software, and to permit persons to whom the Software is fur-
18 * nished to do so, subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
25 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 * THE SOFTWARE.
30 *
31 * Author: Aleksey Sanin <aleksey@aleksey.com>
32 */
33
34 /*
35 * Summary: Provide Canonical XML and Exclusive XML Canonicalization
36 * Description: the c14n modules provides a
37 *
38 * "Canonical XML" implementation
39 * http://www.w3.org/TR/xml-c14n
40 *
41 * and an
42 *
43 * "Exclusive XML Canonicalization" implementation
44 * http://www.w3.org/TR/xml-exc-c14n
45 */
46
47 #ifndef __XML_C14N_H__
48 #define __XML_C14N_H__
49 #ifdef LIBXML_C14N_ENABLED
50 #ifdef LIBXML_OUTPUT_ENABLED
51
52 #ifdef __cplusplus
53 extern "C" {
54 #endif /* __cplusplus */
55
56 #include <libxml/xmlversion.h>
57 #include <libxml/tree.h>
58 #include <libxml/xpath.h>
59
60 /*
61 * XML Canonicazation
62 * http://www.w3.org/TR/xml-c14n
63 *
64 * Exclusive XML Canonicazation
65 * http://www.w3.org/TR/xml-exc-c14n
66 *
67 * Canonical form of an XML document could be created if and only if
68 * a) default attributes (if any) are added to all nodes
69 * b) all character and parsed entity references are resolved
70 * In order to achive this in libxml2 the document MUST be loaded with
71 * following global setings:
72 *
73 * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
74 * xmlSubstituteEntitiesDefault(1);
75 *
76 * or corresponding parser context setting:
77 * xmlParserCtxtPtr ctxt;
78 *
79 * ...
80 * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
81 * ctxt->replaceEntities = 1;
82 * ...
83 */
84
85 /*
86 * xmlC14NMode:
87 *
88 * Predefined values for C14N modes
89 *
90 */
91 typedef enum {
92 XML_C14N_1_0 = 0, /* Origianal C14N 1.0 spec */
93 XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
94 XML_C14N_1_1 = 2 /* C14N 1.1 spec */
95 } xmlC14NMode;
96
97 XMLPUBFUN int XMLCALL
98 xmlC14NDocSaveTo (xmlDocPtr doc,
99 xmlNodeSetPtr nodes,
100 int mode, /* a xmlC14NMode */
101 xmlChar **inclusive_ns_prefixes,
102 int with_comments,
103 xmlOutputBufferPtr buf);
104
105 XMLPUBFUN int XMLCALL
106 xmlC14NDocDumpMemory (xmlDocPtr doc,
107 xmlNodeSetPtr nodes,
108 int mode, /* a xmlC14NMode */
109 xmlChar **inclusive_ns_prefixes,
110 int with_comments,
111 xmlChar **doc_txt_ptr);
112
113 XMLPUBFUN int XMLCALL
114 xmlC14NDocSave (xmlDocPtr doc,
115 xmlNodeSetPtr nodes,
116 int mode, /* a xmlC14NMode */
117 xmlChar **inclusive_ns_prefixes,
118 int with_comments,
119 const char* filename,
120 int compression);
121
122
123 /**
124 * This is the core C14N function
125 */
126 /**
127 * xmlC14NIsVisibleCallback:
128 * @user_data: user data
129 * @node: the curent node
130 * @parent: the parent node
131 *
132 * Signature for a C14N callback on visible nodes
133 *
134 * Returns 1 if the node should be included
135 */
136 typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
137 xmlNodePtr node,
138 xmlNodePtr parent);
139
140 XMLPUBFUN int XMLCALL
141 xmlC14NExecute (xmlDocPtr doc,
142 xmlC14NIsVisibleCallback is_visible_callback,
143 void* user_data,
144 int mode, /* a xmlC14NMode */
145 xmlChar **inclusive_ns_prefixes,
146 int with_comments,
147 xmlOutputBufferPtr buf);
148
149 #ifdef __cplusplus
150 }
151 #endif /* __cplusplus */
152
153 #endif /* LIBXML_OUTPUT_ENABLED */
154 #endif /* LIBXML_C14N_ENABLED */
155 #endif /* __XML_C14N_H__ */
156