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