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