You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 lines
4.9 KiB

4 years ago
  1. /*
  2. * Summary: unfinished XLink detection module
  3. * Description: unfinished XLink detection module
  4. *
  5. * Copy: See Copyright for the status of this software.
  6. *
  7. * Author: Daniel Veillard
  8. */
  9. #ifndef __XML_XLINK_H__
  10. #define __XML_XLINK_H__
  11. #include <libxml/xmlversion.h>
  12. #include <libxml/tree.h>
  13. #ifdef LIBXML_XPTR_ENABLED
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /**
  18. * Various defines for the various Link properties.
  19. *
  20. * NOTE: the link detection layer will try to resolve QName expansion
  21. * of namespaces. If "foo" is the prefix for "http://foo.com/"
  22. * then the link detection layer will expand role="foo:myrole"
  23. * to "http://foo.com/:myrole".
  24. * NOTE: the link detection layer will expand URI-Refences found on
  25. * href attributes by using the base mechanism if found.
  26. */
  27. typedef xmlChar *xlinkHRef;
  28. typedef xmlChar *xlinkRole;
  29. typedef xmlChar *xlinkTitle;
  30. typedef enum {
  31. XLINK_TYPE_NONE = 0,
  32. XLINK_TYPE_SIMPLE,
  33. XLINK_TYPE_EXTENDED,
  34. XLINK_TYPE_EXTENDED_SET
  35. } xlinkType;
  36. typedef enum {
  37. XLINK_SHOW_NONE = 0,
  38. XLINK_SHOW_NEW,
  39. XLINK_SHOW_EMBED,
  40. XLINK_SHOW_REPLACE
  41. } xlinkShow;
  42. typedef enum {
  43. XLINK_ACTUATE_NONE = 0,
  44. XLINK_ACTUATE_AUTO,
  45. XLINK_ACTUATE_ONREQUEST
  46. } xlinkActuate;
  47. /**
  48. * xlinkNodeDetectFunc:
  49. * @ctx: user data pointer
  50. * @node: the node to check
  51. *
  52. * This is the prototype for the link detection routine.
  53. * It calls the default link detection callbacks upon link detection.
  54. */
  55. typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);
  56. /*
  57. * The link detection module interact with the upper layers using
  58. * a set of callback registered at parsing time.
  59. */
  60. /**
  61. * xlinkSimpleLinkFunk:
  62. * @ctx: user data pointer
  63. * @node: the node carrying the link
  64. * @href: the target of the link
  65. * @role: the role string
  66. * @title: the link title
  67. *
  68. * This is the prototype for a simple link detection callback.
  69. */
  70. typedef void
  71. (*xlinkSimpleLinkFunk) (void *ctx,
  72. xmlNodePtr node,
  73. const xlinkHRef href,
  74. const xlinkRole role,
  75. const xlinkTitle title);
  76. /**
  77. * xlinkExtendedLinkFunk:
  78. * @ctx: user data pointer
  79. * @node: the node carrying the link
  80. * @nbLocators: the number of locators detected on the link
  81. * @hrefs: pointer to the array of locator hrefs
  82. * @roles: pointer to the array of locator roles
  83. * @nbArcs: the number of arcs detected on the link
  84. * @from: pointer to the array of source roles found on the arcs
  85. * @to: pointer to the array of target roles found on the arcs
  86. * @show: array of values for the show attributes found on the arcs
  87. * @actuate: array of values for the actuate attributes found on the arcs
  88. * @nbTitles: the number of titles detected on the link
  89. * @title: array of titles detected on the link
  90. * @langs: array of xml:lang values for the titles
  91. *
  92. * This is the prototype for a extended link detection callback.
  93. */
  94. typedef void
  95. (*xlinkExtendedLinkFunk)(void *ctx,
  96. xmlNodePtr node,
  97. int nbLocators,
  98. const xlinkHRef *hrefs,
  99. const xlinkRole *roles,
  100. int nbArcs,
  101. const xlinkRole *from,
  102. const xlinkRole *to,
  103. xlinkShow *show,
  104. xlinkActuate *actuate,
  105. int nbTitles,
  106. const xlinkTitle *titles,
  107. const xmlChar **langs);
  108. /**
  109. * xlinkExtendedLinkSetFunk:
  110. * @ctx: user data pointer
  111. * @node: the node carrying the link
  112. * @nbLocators: the number of locators detected on the link
  113. * @hrefs: pointer to the array of locator hrefs
  114. * @roles: pointer to the array of locator roles
  115. * @nbTitles: the number of titles detected on the link
  116. * @title: array of titles detected on the link
  117. * @langs: array of xml:lang values for the titles
  118. *
  119. * This is the prototype for a extended link set detection callback.
  120. */
  121. typedef void
  122. (*xlinkExtendedLinkSetFunk) (void *ctx,
  123. xmlNodePtr node,
  124. int nbLocators,
  125. const xlinkHRef *hrefs,
  126. const xlinkRole *roles,
  127. int nbTitles,
  128. const xlinkTitle *titles,
  129. const xmlChar **langs);
  130. /**
  131. * This is the structure containing a set of Links detection callbacks.
  132. *
  133. * There is no default xlink callbacks, if one want to get link
  134. * recognition activated, those call backs must be provided before parsing.
  135. */
  136. typedef struct _xlinkHandler xlinkHandler;
  137. typedef xlinkHandler *xlinkHandlerPtr;
  138. struct _xlinkHandler {
  139. xlinkSimpleLinkFunk simple;
  140. xlinkExtendedLinkFunk extended;
  141. xlinkExtendedLinkSetFunk set;
  142. };
  143. /*
  144. * The default detection routine, can be overridden, they call the default
  145. * detection callbacks.
  146. */
  147. XMLPUBFUN xlinkNodeDetectFunc XMLCALL
  148. xlinkGetDefaultDetect (void);
  149. XMLPUBFUN void XMLCALL
  150. xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
  151. /*
  152. * Routines to set/get the default handlers.
  153. */
  154. XMLPUBFUN xlinkHandlerPtr XMLCALL
  155. xlinkGetDefaultHandler (void);
  156. XMLPUBFUN void XMLCALL
  157. xlinkSetDefaultHandler (xlinkHandlerPtr handler);
  158. /*
  159. * Link detection module itself.
  160. */
  161. XMLPUBFUN xlinkType XMLCALL
  162. xlinkIsLink (xmlDocPtr doc,
  163. xmlNodePtr node);
  164. #ifdef __cplusplus
  165. }
  166. #endif
  167. #endif /* LIBXML_XPTR_ENABLED */
  168. #endif /* __XML_XLINK_H__ */