c14n.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <[email protected]>
  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. XMLPUBFUN int XMLCALL
  51. xmlC14NDocSaveTo (xmlDocPtr doc,
  52. xmlNodeSetPtr nodes,
  53. int exclusive,
  54. xmlChar **inclusive_ns_prefixes,
  55. int with_comments,
  56. xmlOutputBufferPtr buf);
  57. XMLPUBFUN int XMLCALL
  58. xmlC14NDocDumpMemory (xmlDocPtr doc,
  59. xmlNodeSetPtr nodes,
  60. int exclusive,
  61. xmlChar **inclusive_ns_prefixes,
  62. int with_comments,
  63. xmlChar **doc_txt_ptr);
  64. XMLPUBFUN int XMLCALL
  65. xmlC14NDocSave (xmlDocPtr doc,
  66. xmlNodeSetPtr nodes,
  67. int exclusive,
  68. xmlChar **inclusive_ns_prefixes,
  69. int with_comments,
  70. const char* filename,
  71. int compression);
  72. /**
  73. * This is the core C14N function
  74. */
  75. typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
  76. xmlNodePtr node,
  77. xmlNodePtr parent);
  78. XMLPUBFUN int XMLCALL
  79. xmlC14NExecute (xmlDocPtr doc,
  80. xmlC14NIsVisibleCallback is_visible_callback,
  81. void* user_data,
  82. int exclusive,
  83. xmlChar **inclusive_ns_prefixes,
  84. int with_comments,
  85. xmlOutputBufferPtr buf);
  86. #ifdef __cplusplus
  87. }
  88. #endif /* __cplusplus */
  89. #endif /* LIBXML_OUTPUT_ENABLED */
  90. #endif /* LIBXML_C14N_ENABLED */
  91. #endif /* __XML_C14N_H__ */