c14n.h 2.7 KB

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