Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 1 | /* |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 2 | * Summary: Provide Canonical XML and Exclusive XML Canonicalization |
| 3 | * Description: the c14n modules provides a |
| 4 | * |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 5 | * "Canonical XML" implementation |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 6 | * http://www.w3.org/TR/xml-c14n |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 7 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 8 | * and an |
| 9 | * |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 10 | * "Exclusive XML Canonicalization" implementation |
| 11 | * http://www.w3.org/TR/xml-exc-c14n |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 12 | |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 13 | * Copy: See Copyright for the status of this software. |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 14 | * |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 15 | * Author: Aleksey Sanin <aleksey@aleksey.com> |
| 16 | */ |
| 17 | #ifndef __XML_C14N_H__ |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 18 | #define __XML_C14N_H__ |
Daniel Veillard | a235132 | 2004-06-27 12:08:10 +0000 | [diff] [blame] | 19 | #ifdef LIBXML_C14N_ENABLED |
Daniel Veillard | a9cce9c | 2003-09-29 13:20:24 +0000 | [diff] [blame] | 20 | #ifdef LIBXML_OUTPUT_ENABLED |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 21 | |
| 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 24 | #endif /* __cplusplus */ |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 25 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 26 | #include <libxml/xmlversion.h> |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 27 | #include <libxml/tree.h> |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 28 | #include <libxml/xpath.h> |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 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 |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 40 | * In order to achive this in libxml2 the document MUST be loaded with |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 41 | * following global setings: |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 42 | * |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 43 | * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; |
| 44 | * xmlSubstituteEntitiesDefault(1); |
| 45 | * |
| 46 | * or corresponding parser context setting: |
| 47 | * xmlParserCtxtPtr ctxt; |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 48 | * |
| 49 | * ... |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 50 | * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS; |
| 51 | * ctxt->replaceEntities = 1; |
| 52 | * ... |
| 53 | */ |
Aleksey Sanin | 2c135a1 | 2002-08-01 06:31:50 +0000 | [diff] [blame] | 54 | |
Aleksey Sanin | 8386824 | 2009-07-09 10:26:22 +0200 | [diff] [blame] | 55 | /* |
| 56 | * xmlC14NMode: |
Daniel Veillard | f8e3db0 | 2012-09-11 13:26:36 +0800 | [diff] [blame] | 57 | * |
Aleksey Sanin | 8386824 | 2009-07-09 10:26:22 +0200 | [diff] [blame] | 58 | * Predefined values for C14N modes |
| 59 | * |
| 60 | */ |
| 61 | typedef enum { |
| 62 | XML_C14N_1_0 = 0, /* Origianal C14N 1.0 spec */ |
| 63 | XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */ |
| 64 | XML_C14N_1_1 = 2 /* C14N 1.1 spec */ |
| 65 | } xmlC14NMode; |
Aleksey Sanin | 2c135a1 | 2002-08-01 06:31:50 +0000 | [diff] [blame] | 66 | |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 67 | XMLPUBFUN int XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 68 | xmlC14NDocSaveTo (xmlDocPtr doc, |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 69 | xmlNodeSetPtr nodes, |
Aleksey Sanin | 8386824 | 2009-07-09 10:26:22 +0200 | [diff] [blame] | 70 | int mode, /* a xmlC14NMode */ |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 71 | xmlChar **inclusive_ns_prefixes, |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 72 | int with_comments, |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 73 | xmlOutputBufferPtr buf); |
| 74 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 75 | XMLPUBFUN int XMLCALL |
| 76 | xmlC14NDocDumpMemory (xmlDocPtr doc, |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 77 | xmlNodeSetPtr nodes, |
Aleksey Sanin | 175beba | 2009-07-09 22:54:00 +0200 | [diff] [blame] | 78 | int mode, /* a xmlC14NMode */ |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 79 | xmlChar **inclusive_ns_prefixes, |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 80 | int with_comments, |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 81 | xmlChar **doc_txt_ptr); |
| 82 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 83 | XMLPUBFUN int XMLCALL |
| 84 | xmlC14NDocSave (xmlDocPtr doc, |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 85 | xmlNodeSetPtr nodes, |
Aleksey Sanin | 175beba | 2009-07-09 22:54:00 +0200 | [diff] [blame] | 86 | int mode, /* a xmlC14NMode */ |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 87 | xmlChar **inclusive_ns_prefixes, |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 88 | int with_comments, |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 89 | const char* filename, |
| 90 | int compression); |
| 91 | |
| 92 | |
Aleksey Sanin | 2c135a1 | 2002-08-01 06:31:50 +0000 | [diff] [blame] | 93 | /** |
| 94 | * This is the core C14N function |
| 95 | */ |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 96 | /** |
| 97 | * xmlC14NIsVisibleCallback: |
| 98 | * @user_data: user data |
| 99 | * @node: the curent node |
| 100 | * @parent: the parent node |
| 101 | * |
| 102 | * Signature for a C14N callback on visible nodes |
| 103 | * |
| 104 | * Returns 1 if the node should be included |
| 105 | */ |
| 106 | typedef int (*xmlC14NIsVisibleCallback) (void* user_data, |
Aleksey Sanin | 2c135a1 | 2002-08-01 06:31:50 +0000 | [diff] [blame] | 107 | xmlNodePtr node, |
| 108 | xmlNodePtr parent); |
| 109 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 110 | XMLPUBFUN int XMLCALL |
| 111 | xmlC14NExecute (xmlDocPtr doc, |
Aleksey Sanin | 2c135a1 | 2002-08-01 06:31:50 +0000 | [diff] [blame] | 112 | xmlC14NIsVisibleCallback is_visible_callback, |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 113 | void* user_data, |
Aleksey Sanin | 175beba | 2009-07-09 22:54:00 +0200 | [diff] [blame] | 114 | int mode, /* a xmlC14NMode */ |
Aleksey Sanin | 2c135a1 | 2002-08-01 06:31:50 +0000 | [diff] [blame] | 115 | xmlChar **inclusive_ns_prefixes, |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 116 | int with_comments, |
Aleksey Sanin | 2c135a1 | 2002-08-01 06:31:50 +0000 | [diff] [blame] | 117 | xmlOutputBufferPtr buf); |
| 118 | |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 119 | #ifdef __cplusplus |
| 120 | } |
| 121 | #endif /* __cplusplus */ |
| 122 | |
Daniel Veillard | a9cce9c | 2003-09-29 13:20:24 +0000 | [diff] [blame] | 123 | #endif /* LIBXML_OUTPUT_ENABLED */ |
Daniel Veillard | a235132 | 2004-06-27 12:08:10 +0000 | [diff] [blame] | 124 | #endif /* LIBXML_C14N_ENABLED */ |
Daniel Veillard | 044fc6b | 2002-03-04 17:09:44 +0000 | [diff] [blame] | 125 | #endif /* __XML_C14N_H__ */ |
| 126 | |