c14n.h revision 60a4c356ee9ce5e9ccb23347c0381f0436192691
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#ifdef LIBXML_C14N_ENABLED
20#ifdef LIBXML_OUTPUT_ENABLED
21
22#ifdef __cplusplus
23extern "C" {
24#endif /* __cplusplus */
25
26#include <libxml/xmlversion.h>
27#include <libxml/tree.h>
28#include <libxml/xpath.h>
29
30/*
31 * XML Canonicazation
32 * http://www.w3.org/TR/xml-c14n
33 *
34 * Exclusive XML Canonicazation
35 * http://www.w3.org/TR/xml-exc-c14n
36 *
37 * Canonical form of an XML document could be created if and only if
38 *  a) default attributes (if any) are added to all nodes
39 *  b) all character and parsed entity references are resolved
40 * In order to achive this in libxml2 the document MUST be loaded with
41 * following global setings:
42 *
43 *    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
44 *    xmlSubstituteEntitiesDefault(1);
45 *
46 * or corresponding parser context setting:
47 *    xmlParserCtxtPtr ctxt;
48 *
49 *    ...
50 *    ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
51 *    ctxt->replaceEntities = 1;
52 *    ...
53 */
54
55
56XMLPUBFUN int XMLCALL
57		xmlC14NDocSaveTo	(xmlDocPtr doc,
58					 xmlNodeSetPtr nodes,
59					 int exclusive,
60					 xmlChar **inclusive_ns_prefixes,
61					 int with_comments,
62					 xmlOutputBufferPtr buf);
63
64XMLPUBFUN int XMLCALL
65		xmlC14NDocDumpMemory	(xmlDocPtr doc,
66					 xmlNodeSetPtr nodes,
67					 int exclusive,
68					 xmlChar **inclusive_ns_prefixes,
69					 int with_comments,
70					 xmlChar **doc_txt_ptr);
71
72XMLPUBFUN int XMLCALL
73		xmlC14NDocSave		(xmlDocPtr doc,
74					 xmlNodeSetPtr nodes,
75					 int exclusive,
76					 xmlChar **inclusive_ns_prefixes,
77					 int with_comments,
78					 const char* filename,
79					 int compression);
80
81
82/**
83 * This is the core C14N function
84 */
85/**
86 * xmlC14NIsVisibleCallback:
87 * @user_data: user data
88 * @node: the curent node
89 * @parent: the parent node
90 *
91 * Signature for a C14N callback on visible nodes
92 *
93 * Returns 1 if the node should be included
94 */
95typedef int (*xmlC14NIsVisibleCallback)	(void* user_data,
96					 xmlNodePtr node,
97					 xmlNodePtr parent);
98
99XMLPUBFUN int XMLCALL
100		xmlC14NExecute		(xmlDocPtr doc,
101					 xmlC14NIsVisibleCallback is_visible_callback,
102					 void* user_data,
103					 int exclusive,
104					 xmlChar **inclusive_ns_prefixes,
105					 int with_comments,
106					 xmlOutputBufferPtr buf);
107
108#ifdef __cplusplus
109}
110#endif /* __cplusplus */
111
112#endif /* LIBXML_OUTPUT_ENABLED */
113#endif /* LIBXML_C14N_ENABLED */
114#endif /* __XML_C14N_H__ */
115
116