c14n.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 global settings:
  37. *
  38. * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
  39. * xmlSubstituteEntitiesDefault(1);
  40. *
  41. * or corresponding parser context setting:
  42. * xmlParserCtxtPtr ctxt;
  43. *
  44. * ...
  45. * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
  46. * ctxt->replaceEntities = 1;
  47. * ...
  48. */
  49. /*
  50. * xmlC14NMode:
  51. *
  52. * Predefined values for C14N modes
  53. *
  54. */
  55. typedef enum {
  56. XML_C14N_1_0 = 0, /* Original C14N 1.0 spec */
  57. XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
  58. XML_C14N_1_1 = 2 /* C14N 1.1 spec */
  59. } xmlC14NMode;
  60. XMLPUBFUN int
  61. xmlC14NDocSaveTo (xmlDocPtr doc,
  62. xmlNodeSetPtr nodes,
  63. int mode, /* a xmlC14NMode */
  64. xmlChar **inclusive_ns_prefixes,
  65. int with_comments,
  66. xmlOutputBufferPtr buf);
  67. XMLPUBFUN int
  68. xmlC14NDocDumpMemory (xmlDocPtr doc,
  69. xmlNodeSetPtr nodes,
  70. int mode, /* a xmlC14NMode */
  71. xmlChar **inclusive_ns_prefixes,
  72. int with_comments,
  73. xmlChar **doc_txt_ptr);
  74. XMLPUBFUN int
  75. xmlC14NDocSave (xmlDocPtr doc,
  76. xmlNodeSetPtr nodes,
  77. int mode, /* a xmlC14NMode */
  78. xmlChar **inclusive_ns_prefixes,
  79. int with_comments,
  80. const char* filename,
  81. int compression);
  82. /**
  83. * This is the core C14N function
  84. */
  85. /**
  86. * xmlC14NIsVisibleCallback:
  87. * @user_data: user data
  88. * @node: the current node
  89. * @parent: the parent node
  90. *
  91. * Signature for a C14N callback on visible nodes
  92. *
  93. * Returns 1 if the node should be included
  94. */
  95. typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
  96. xmlNodePtr node,
  97. xmlNodePtr parent);
  98. XMLPUBFUN int
  99. xmlC14NExecute (xmlDocPtr doc,
  100. xmlC14NIsVisibleCallback is_visible_callback,
  101. void* user_data,
  102. int mode, /* a xmlC14NMode */
  103. xmlChar **inclusive_ns_prefixes,
  104. int with_comments,
  105. xmlOutputBufferPtr buf);
  106. #ifdef __cplusplus
  107. }
  108. #endif /* __cplusplus */
  109. #endif /* LIBXML_C14N_ENABLED */
  110. #endif /* __XML_C14N_H__ */