blob: e8fdf5554780f2b15dcd25d10e559237473bf514 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
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 *
Daniel Veillardc5d64342001-06-24 12:13:24 +000010 * daniel@veillard.com
Owen Taylor3473f882001-02-23 17:55:21 +000011 */
12
13#ifndef __XML_XLINK_H__
14#define __XML_XLINK_H__
15
16#include <libxml/tree.h>
17
18#ifdef __cplusplus
19extern "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 */
31typedef xmlChar *xlinkHRef;
32typedef xmlChar *xlinkRole;
33typedef xmlChar *xlinkTitle;
34
35typedef enum {
36 XLINK_TYPE_NONE = 0,
37 XLINK_TYPE_SIMPLE,
38 XLINK_TYPE_EXTENDED,
39 XLINK_TYPE_EXTENDED_SET
40} xlinkType;
41
42typedef enum {
43 XLINK_SHOW_NONE = 0,
44 XLINK_SHOW_NEW,
45 XLINK_SHOW_EMBED,
46 XLINK_SHOW_REPLACE
47} xlinkShow;
48
49typedef enum {
50 XLINK_ACTUATE_NONE = 0,
51 XLINK_ACTUATE_AUTO,
52 XLINK_ACTUATE_ONREQUEST
53} 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 */
Daniel Veillard5e2dace2001-07-18 19:30:27 +000063typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);
Owen Taylor3473f882001-02-23 17:55:21 +000064
65/**
Daniel Veillardcbaf3992001-12-31 16:16:02 +000066 * The link detection module interact with the upper layers using
Owen Taylor3473f882001-02-23 17:55:21 +000067 * 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 */
80typedef void
81(*xlinkSimpleLinkFunk) (void *ctx,
82 xmlNodePtr node,
83 const xlinkHRef href,
84 const xlinkRole role,
85 const xlinkTitle title);
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 */
105typedef 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);
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 */
133typedef 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);
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 */
149typedef struct _xlinkHandler xlinkHandler;
150typedef xlinkHandler *xlinkHandlerPtr;
151struct _xlinkHandler {
152 xlinkSimpleLinkFunk simple;
153 xlinkExtendedLinkFunk extended;
154 xlinkExtendedLinkSetFunk set;
155};
156
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000157/*
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000158 * the default detection routine, can be overridden, they call the default
Owen Taylor3473f882001-02-23 17:55:21 +0000159 * detection callbacks.
160 */
161
162xlinkNodeDetectFunc xlinkGetDefaultDetect (void);
163void xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
164
Daniel Veillardf69bb4b2001-05-19 13:24:56 +0000165/*
Owen Taylor3473f882001-02-23 17:55:21 +0000166 * Routines to set/get the default handlers.
167 */
168xlinkHandlerPtr xlinkGetDefaultHandler (void);
169void xlinkSetDefaultHandler (xlinkHandlerPtr handler);
170
171/*
172 * Link detection module itself.
173 */
174xlinkType xlinkIsLink (xmlDocPtr doc,
175 xmlNodePtr node);
176
177#ifdef __cplusplus
178}
179#endif
180#endif /* __XML_XLINK_H__ */