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