• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Summary: Provide Canonical XML and Exclusive XML Canonicalization
3  * Description: the c14n modules provides a
4  *
5  * "Canonical XML" implementation
6  * http://www.w3.org/TR/xml-c14n
7  *
8  * and an
9  *
10  * "Exclusive XML Canonicalization" implementation
11  * http://www.w3.org/TR/xml-exc-c14n
12 
13  * Copy: See Copyright for the status of this software.
14  *
15  * Author: Aleksey Sanin <aleksey@aleksey.com>
16  */
17 #ifndef __XML_C14N_H__
18 #define __XML_C14N_H__
19 
20 #include <libxml/xmlversion.h>
21 
22 #ifdef LIBXML_C14N_ENABLED
23 
24 #include <libxml/tree.h>
25 #include <libxml/xpath.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 
31 /*
32  * XML Canonicalization
33  * http://www.w3.org/TR/xml-c14n
34  *
35  * Exclusive XML Canonicalization
36  * http://www.w3.org/TR/xml-exc-c14n
37  *
38  * Canonical form of an XML document could be created if and only if
39  *  a) default attributes (if any) are added to all nodes
40  *  b) all character and parsed entity references are resolved
41  * In order to achieve this in libxml2 the document MUST be loaded with
42  * following global settings:
43  *
44  *    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
45  *    xmlSubstituteEntitiesDefault(1);
46  *
47  * or corresponding parser context setting:
48  *    xmlParserCtxtPtr ctxt;
49  *
50  *    ...
51  *    ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
52  *    ctxt->replaceEntities = 1;
53  *    ...
54  */
55 
56 /*
57  * xmlC14NMode:
58  *
59  * Predefined values for C14N modes
60  *
61  */
62 typedef enum {
63     XML_C14N_1_0            = 0,    /* Original C14N 1.0 spec */
64     XML_C14N_EXCLUSIVE_1_0  = 1,    /* Exclusive C14N 1.0 spec */
65     XML_C14N_1_1            = 2     /* C14N 1.1 spec */
66 } xmlC14NMode;
67 
68 XMLPUBFUN int
69 		xmlC14NDocSaveTo	(xmlDocPtr doc,
70 					 xmlNodeSetPtr nodes,
71 					 int mode, /* a xmlC14NMode */
72 					 xmlChar **inclusive_ns_prefixes,
73 					 int with_comments,
74 					 xmlOutputBufferPtr buf);
75 
76 XMLPUBFUN int
77 		xmlC14NDocDumpMemory	(xmlDocPtr doc,
78 					 xmlNodeSetPtr nodes,
79 					 int mode, /* a xmlC14NMode */
80 					 xmlChar **inclusive_ns_prefixes,
81 					 int with_comments,
82 					 xmlChar **doc_txt_ptr);
83 
84 XMLPUBFUN int
85 		xmlC14NDocSave		(xmlDocPtr doc,
86 					 xmlNodeSetPtr nodes,
87 					 int mode, /* a xmlC14NMode */
88 					 xmlChar **inclusive_ns_prefixes,
89 					 int with_comments,
90 					 const char* filename,
91 					 int compression);
92 
93 
94 /**
95  * This is the core C14N function
96  */
97 /**
98  * xmlC14NIsVisibleCallback:
99  * @user_data: user data
100  * @node: the current node
101  * @parent: the parent node
102  *
103  * Signature for a C14N callback on visible nodes
104  *
105  * Returns 1 if the node should be included
106  */
107 typedef int (*xmlC14NIsVisibleCallback)	(void* user_data,
108 					 xmlNodePtr node,
109 					 xmlNodePtr parent);
110 
111 XMLPUBFUN int
112 		xmlC14NExecute		(xmlDocPtr doc,
113 					 xmlC14NIsVisibleCallback is_visible_callback,
114 					 void* user_data,
115 					 int mode, /* a xmlC14NMode */
116 					 xmlChar **inclusive_ns_prefixes,
117 					 int with_comments,
118 					 xmlOutputBufferPtr buf);
119 
120 #ifdef __cplusplus
121 }
122 #endif /* __cplusplus */
123 
124 #endif /* LIBXML_C14N_ENABLED */
125 #endif /* __XML_C14N_H__ */
126 
127