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