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