blob: b8971d92046128348f024cf6ad6f5b0e4dcd69f6 [file] [log] [blame]
Daniel Veillard044fc6b2002-03-04 17:09:44 +00001/*
Daniel Veillardbe586972003-11-18 20:56:51 +00002 * Summary: Provide Canonical XML and Exclusive XML Canonicalization
3 * Description: the c14n modules provides a
4 *
Daniel Veillarddee23482008-04-11 12:58:43 +00005 * "Canonical XML" implementation
Daniel Veillard044fc6b2002-03-04 17:09:44 +00006 * http://www.w3.org/TR/xml-c14n
Daniel Veillarddee23482008-04-11 12:58:43 +00007 *
Daniel Veillardbe586972003-11-18 20:56:51 +00008 * and an
9 *
Daniel Veillard044fc6b2002-03-04 17:09:44 +000010 * "Exclusive XML Canonicalization" implementation
11 * http://www.w3.org/TR/xml-exc-c14n
Daniel Veillarddee23482008-04-11 12:58:43 +000012
Daniel Veillardbe586972003-11-18 20:56:51 +000013 * Copy: See Copyright for the status of this software.
Daniel Veillarddee23482008-04-11 12:58:43 +000014 *
Daniel Veillard044fc6b2002-03-04 17:09:44 +000015 * Author: Aleksey Sanin <aleksey@aleksey.com>
16 */
17#ifndef __XML_C14N_H__
Daniel Veillarddee23482008-04-11 12:58:43 +000018#define __XML_C14N_H__
Daniel Veillarda2351322004-06-27 12:08:10 +000019#ifdef LIBXML_C14N_ENABLED
Daniel Veillarda9cce9c2003-09-29 13:20:24 +000020#ifdef LIBXML_OUTPUT_ENABLED
Daniel Veillard044fc6b2002-03-04 17:09:44 +000021
22#ifdef __cplusplus
23extern "C" {
Daniel Veillarddee23482008-04-11 12:58:43 +000024#endif /* __cplusplus */
Daniel Veillard044fc6b2002-03-04 17:09:44 +000025
Igor Zlatkovic76874e42003-08-25 09:05:12 +000026#include <libxml/xmlversion.h>
Daniel Veillard044fc6b2002-03-04 17:09:44 +000027#include <libxml/tree.h>
Daniel Veillarddee23482008-04-11 12:58:43 +000028#include <libxml/xpath.h>
Daniel Veillard044fc6b2002-03-04 17:09:44 +000029
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 Veillarddee23482008-04-11 12:58:43 +000040 * In order to achive this in libxml2 the document MUST be loaded with
Daniel Veillard044fc6b2002-03-04 17:09:44 +000041 * following global setings:
Daniel Veillarddee23482008-04-11 12:58:43 +000042 *
Daniel Veillard044fc6b2002-03-04 17:09:44 +000043 * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
44 * xmlSubstituteEntitiesDefault(1);
45 *
46 * or corresponding parser context setting:
47 * xmlParserCtxtPtr ctxt;
Daniel Veillarddee23482008-04-11 12:58:43 +000048 *
49 * ...
Daniel Veillard044fc6b2002-03-04 17:09:44 +000050 * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
51 * ctxt->replaceEntities = 1;
52 * ...
53 */
Aleksey Sanin2c135a12002-08-01 06:31:50 +000054
Aleksey Sanin83868242009-07-09 10:26:22 +020055/*
56 * xmlC14NMode:
Daniel Veillardf8e3db02012-09-11 13:26:36 +080057 *
Aleksey Sanin83868242009-07-09 10:26:22 +020058 * Predefined values for C14N modes
59 *
60 */
61typedef 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 Sanin2c135a12002-08-01 06:31:50 +000066
Daniel Veillarddee23482008-04-11 12:58:43 +000067XMLPUBFUN int XMLCALL
Igor Zlatkovic76874e42003-08-25 09:05:12 +000068 xmlC14NDocSaveTo (xmlDocPtr doc,
Daniel Veillard044fc6b2002-03-04 17:09:44 +000069 xmlNodeSetPtr nodes,
Aleksey Sanin83868242009-07-09 10:26:22 +020070 int mode, /* a xmlC14NMode */
Daniel Veillard044fc6b2002-03-04 17:09:44 +000071 xmlChar **inclusive_ns_prefixes,
Daniel Veillarddee23482008-04-11 12:58:43 +000072 int with_comments,
Daniel Veillard044fc6b2002-03-04 17:09:44 +000073 xmlOutputBufferPtr buf);
74
Igor Zlatkovic76874e42003-08-25 09:05:12 +000075XMLPUBFUN int XMLCALL
76 xmlC14NDocDumpMemory (xmlDocPtr doc,
Daniel Veillard044fc6b2002-03-04 17:09:44 +000077 xmlNodeSetPtr nodes,
Aleksey Sanin175beba2009-07-09 22:54:00 +020078 int mode, /* a xmlC14NMode */
Daniel Veillard044fc6b2002-03-04 17:09:44 +000079 xmlChar **inclusive_ns_prefixes,
Daniel Veillarddee23482008-04-11 12:58:43 +000080 int with_comments,
Daniel Veillard044fc6b2002-03-04 17:09:44 +000081 xmlChar **doc_txt_ptr);
82
Igor Zlatkovic76874e42003-08-25 09:05:12 +000083XMLPUBFUN int XMLCALL
84 xmlC14NDocSave (xmlDocPtr doc,
Daniel Veillard044fc6b2002-03-04 17:09:44 +000085 xmlNodeSetPtr nodes,
Aleksey Sanin175beba2009-07-09 22:54:00 +020086 int mode, /* a xmlC14NMode */
Daniel Veillard044fc6b2002-03-04 17:09:44 +000087 xmlChar **inclusive_ns_prefixes,
Daniel Veillarddee23482008-04-11 12:58:43 +000088 int with_comments,
Daniel Veillard044fc6b2002-03-04 17:09:44 +000089 const char* filename,
90 int compression);
91
92
Aleksey Sanin2c135a12002-08-01 06:31:50 +000093/**
94 * This is the core C14N function
95 */
Daniel Veillarddee23482008-04-11 12:58:43 +000096/**
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 */
106typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
Aleksey Sanin2c135a12002-08-01 06:31:50 +0000107 xmlNodePtr node,
108 xmlNodePtr parent);
109
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000110XMLPUBFUN int XMLCALL
111 xmlC14NExecute (xmlDocPtr doc,
Aleksey Sanin2c135a12002-08-01 06:31:50 +0000112 xmlC14NIsVisibleCallback is_visible_callback,
Daniel Veillarddee23482008-04-11 12:58:43 +0000113 void* user_data,
Aleksey Sanin175beba2009-07-09 22:54:00 +0200114 int mode, /* a xmlC14NMode */
Aleksey Sanin2c135a12002-08-01 06:31:50 +0000115 xmlChar **inclusive_ns_prefixes,
Daniel Veillarddee23482008-04-11 12:58:43 +0000116 int with_comments,
Aleksey Sanin2c135a12002-08-01 06:31:50 +0000117 xmlOutputBufferPtr buf);
118
Daniel Veillard044fc6b2002-03-04 17:09:44 +0000119#ifdef __cplusplus
120}
121#endif /* __cplusplus */
122
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000123#endif /* LIBXML_OUTPUT_ENABLED */
Daniel Veillarda2351322004-06-27 12:08:10 +0000124#endif /* LIBXML_C14N_ENABLED */
Daniel Veillard044fc6b2002-03-04 17:09:44 +0000125#endif /* __XML_C14N_H__ */
126