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 <[email protected]> 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 options: XML_PARSE_DTDATTR | XML_PARSE_NOENT 43 */ 44 45 /* 46 * xmlC14NMode: 47 * 48 * Predefined values for C14N modes 49 * 50 */ 51 typedef enum { 52 XML_C14N_1_0 = 0, /* Original C14N 1.0 spec */ 53 XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */ 54 XML_C14N_1_1 = 2 /* C14N 1.1 spec */ 55 } xmlC14NMode; 56 57 XMLPUBFUN int 58 xmlC14NDocSaveTo (xmlDocPtr doc, 59 xmlNodeSetPtr nodes, 60 int mode, /* a xmlC14NMode */ 61 xmlChar **inclusive_ns_prefixes, 62 int with_comments, 63 xmlOutputBufferPtr buf); 64 65 XMLPUBFUN int 66 xmlC14NDocDumpMemory (xmlDocPtr doc, 67 xmlNodeSetPtr nodes, 68 int mode, /* a xmlC14NMode */ 69 xmlChar **inclusive_ns_prefixes, 70 int with_comments, 71 xmlChar **doc_txt_ptr); 72 73 XMLPUBFUN int 74 xmlC14NDocSave (xmlDocPtr doc, 75 xmlNodeSetPtr nodes, 76 int mode, /* a xmlC14NMode */ 77 xmlChar **inclusive_ns_prefixes, 78 int with_comments, 79 const char* filename, 80 int compression); 81 82 83 /** 84 * This is the core C14N function 85 */ 86 /** 87 * xmlC14NIsVisibleCallback: 88 * @user_data: user data 89 * @node: the current node 90 * @parent: the parent node 91 * 92 * Signature for a C14N callback on visible nodes 93 * 94 * Returns 1 if the node should be included 95 */ 96 typedef int (*xmlC14NIsVisibleCallback) (void* user_data, 97 xmlNodePtr node, 98 xmlNodePtr parent); 99 100 XMLPUBFUN int 101 xmlC14NExecute (xmlDocPtr doc, 102 xmlC14NIsVisibleCallback is_visible_callback, 103 void* user_data, 104 int mode, /* a xmlC14NMode */ 105 xmlChar **inclusive_ns_prefixes, 106 int with_comments, 107 xmlOutputBufferPtr buf); 108 109 #ifdef __cplusplus 110 } 111 #endif /* __cplusplus */ 112 113 #endif /* LIBXML_C14N_ENABLED */ 114 #endif /* __XML_C14N_H__ */ 115 116