c14n.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #ifdef LIBXML_C14N_ENABLED
  19. #ifdef LIBXML_OUTPUT_ENABLED
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif /* __cplusplus */
  23. #include <libxml/xmlversion.h>
  24. #include <libxml/tree.h>
  25. #include <libxml/xpath.h>
  26. /*
  27. * XML Canonicazation
  28. * http://www.w3.org/TR/xml-c14n
  29. *
  30. * Exclusive XML Canonicazation
  31. * http://www.w3.org/TR/xml-exc-c14n
  32. *
  33. * Canonical form of an XML document could be created if and only if
  34. * a) default attributes (if any) are added to all nodes
  35. * b) all character and parsed entity references are resolved
  36. * In order to achive this in libxml2 the document MUST be loaded with
  37. * following global setings:
  38. *
  39. * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
  40. * xmlSubstituteEntitiesDefault(1);
  41. *
  42. * or corresponding parser context setting:
  43. * xmlParserCtxtPtr ctxt;
  44. *
  45. * ...
  46. * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
  47. * ctxt->replaceEntities = 1;
  48. * ...
  49. */
  50. /*
  51. * xmlC14NMode:
  52. *
  53. * Predefined values for C14N modes
  54. *
  55. */
  56. typedef enum {
  57. XML_C14N_1_0 = 0, /* Origianal C14N 1.0 spec */
  58. XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
  59. XML_C14N_1_1 = 2 /* C14N 1.1 spec */
  60. }
  61. xmlC14NMode;
  62. XMLPUBFUN int XMLCALL
  63. xmlC14NDocSaveTo (xmlDocPtr doc,
  64. xmlNodeSetPtr nodes,
  65. int mode, /* a xmlC14NMode */
  66. xmlChar **inclusive_ns_prefixes,
  67. int with_comments,
  68. xmlOutputBufferPtr buf);
  69. XMLPUBFUN int XMLCALL
  70. xmlC14NDocDumpMemory (xmlDocPtr doc,
  71. xmlNodeSetPtr nodes,
  72. int mode, /* a xmlC14NMode */
  73. xmlChar **inclusive_ns_prefixes,
  74. int with_comments,
  75. xmlChar **doc_txt_ptr);
  76. XMLPUBFUN int XMLCALL
  77. xmlC14NDocSave (xmlDocPtr doc,
  78. xmlNodeSetPtr nodes,
  79. int mode, /* a xmlC14NMode */
  80. xmlChar **inclusive_ns_prefixes,
  81. int with_comments,
  82. const char* filename,
  83. int compression);
  84. /**
  85. * This is the core C14N function
  86. */
  87. /**
  88. * xmlC14NIsVisibleCallback:
  89. * @user_data: user data
  90. * @node: the curent node
  91. * @parent: the parent node
  92. *
  93. * Signature for a C14N callback on visible nodes
  94. *
  95. * Returns 1 if the node should be included
  96. */
  97. typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
  98. xmlNodePtr node,
  99. xmlNodePtr parent);
  100. XMLPUBFUN int XMLCALL
  101. xmlC14NExecute (xmlDocPtr doc,
  102. xmlC14NIsVisibleCallback is_visible_callback,
  103. void* user_data,
  104. int mode, /* a xmlC14NMode */
  105. xmlChar **inclusive_ns_prefixes,
  106. int with_comments,
  107. xmlOutputBufferPtr buf);
  108. #ifdef __cplusplus
  109. }
  110. #endif /* __cplusplus */
  111. #endif /* LIBXML_OUTPUT_ENABLED */
  112. #endif /* LIBXML_C14N_ENABLED */
  113. #endif /* __XML_C14N_H__ */