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. #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. } xmlC14NMode;
  61. XMLPUBFUN int XMLCALL
  62. xmlC14NDocSaveTo (xmlDocPtr doc,
  63. xmlNodeSetPtr nodes,
  64. int mode, /* a xmlC14NMode */
  65. xmlChar **inclusive_ns_prefixes,
  66. int with_comments,
  67. xmlOutputBufferPtr buf);
  68. XMLPUBFUN int XMLCALL
  69. xmlC14NDocDumpMemory (xmlDocPtr doc,
  70. xmlNodeSetPtr nodes,
  71. int mode, /* a xmlC14NMode */
  72. xmlChar **inclusive_ns_prefixes,
  73. int with_comments,
  74. xmlChar **doc_txt_ptr);
  75. XMLPUBFUN int XMLCALL
  76. xmlC14NDocSave (xmlDocPtr doc,
  77. xmlNodeSetPtr nodes,
  78. int mode, /* a xmlC14NMode */
  79. xmlChar **inclusive_ns_prefixes,
  80. int with_comments,
  81. const char* filename,
  82. int compression);
  83. /**
  84. * This is the core C14N function
  85. */
  86. /**
  87. * xmlC14NIsVisibleCallback:
  88. * @user_data: user data
  89. * @node: the curent node
  90. * @parent: the parent node
  91. *
  92. * Signature for a C14N callback on visible nodes
  93. *
  94. * Returns 1 if the node should be included
  95. */
  96. typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
  97. xmlNodePtr node,
  98. xmlNodePtr parent);
  99. XMLPUBFUN int XMLCALL
  100. xmlC14NExecute (xmlDocPtr doc,
  101. xmlC14NIsVisibleCallback is_visible_callback,
  102. void* user_data,
  103. int mode, /* a xmlC14NMode */
  104. xmlChar **inclusive_ns_prefixes,
  105. int with_comments,
  106. xmlOutputBufferPtr buf);
  107. #ifdef __cplusplus
  108. }
  109. #endif /* __cplusplus */
  110. #endif /* LIBXML_OUTPUT_ENABLED */
  111. #endif /* LIBXML_C14N_ENABLED */
  112. #endif /* __XML_C14N_H__ */