00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00020 #ifndef APR_XML_H
00021 #define APR_XML_H
00022 
00028 #include "apr_pools.h"
00029 #include "apr_tables.h"
00030 #include "apr_file_io.h"
00031 
00032 #include "apu.h"
00033 #if APR_CHARSET_EBCDIC
00034 #include "apr_xlate.h"
00035 #endif
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00045 
00046 
00047 
00048 
00050 typedef struct apr_text apr_text;
00051 
00053 struct apr_text {
00055     const char *text;
00057     struct apr_text *next;
00058 };
00059 
00061 typedef struct apr_text_header apr_text_header;
00062 
00064 struct apr_text_header {
00066     apr_text *first;
00068     apr_text *last;
00069 };
00070 
00077 APU_DECLARE(void) apr_text_append(apr_pool_t *p, apr_text_header *hdr,
00078                                   const char *text);
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 #define APR_XML_NS_DAV_ID       0       
00134 #define APR_XML_NS_NONE         -10     
00136 #define APR_XML_NS_ERROR_BASE   -100    
00138 #define APR_XML_NS_IS_ERROR(e)  ((e) <= APR_XML_NS_ERROR_BASE)
00139 
00141 typedef struct apr_xml_attr apr_xml_attr;
00143 typedef struct apr_xml_elem apr_xml_elem;
00145 typedef struct apr_xml_doc apr_xml_doc;
00146 
00148 struct apr_xml_attr {
00150     const char *name;
00152     int ns;
00153 
00155     const char *value;
00156 
00158     struct apr_xml_attr *next;
00159 };
00160 
00162 struct apr_xml_elem {
00164     const char *name;
00166     int ns;
00168     const char *lang;
00169 
00171     apr_text_header first_cdata;
00173     apr_text_header following_cdata;
00174 
00176     struct apr_xml_elem *parent;        
00178     struct apr_xml_elem *next;  
00180     struct apr_xml_elem *first_child;
00182     struct apr_xml_attr *attr;          
00183 
00184     
00186     struct apr_xml_elem *last_child;
00188     struct apr_xml_ns_scope *ns_scope;
00189 
00190     
00192     void *priv;
00193 };
00194 
00196 #define APR_XML_ELEM_IS_EMPTY(e) ((e)->first_child == NULL && \
00197                                   (e)->first_cdata.first == NULL)
00198 
00200 struct apr_xml_doc {
00202     apr_xml_elem *root; 
00204     apr_array_header_t *namespaces;
00205 };
00206 
00208 typedef struct apr_xml_parser apr_xml_parser;
00209 
00215 APU_DECLARE(apr_xml_parser *) apr_xml_parser_create(apr_pool_t *pool);
00216 
00227 APU_DECLARE(apr_status_t) apr_xml_parse_file(apr_pool_t *p,
00228                                              apr_xml_parser **parser,
00229                                              apr_xml_doc **ppdoc,
00230                                              apr_file_t *xmlfd,
00231                                              apr_size_t buffer_length);
00232 
00233 
00242 APU_DECLARE(apr_status_t) apr_xml_parser_feed(apr_xml_parser *parser,
00243                                               const char *data,
00244                                               apr_size_t len);
00245 
00254 APU_DECLARE(apr_status_t) apr_xml_parser_done(apr_xml_parser *parser,
00255                                               apr_xml_doc **pdoc);
00256 
00264 APU_DECLARE(char *) apr_xml_parser_geterror(apr_xml_parser *parser,
00265                                             char *errbuf,
00266                                             apr_size_t errbufsize);
00267 
00268 
00285 APU_DECLARE(void) apr_xml_to_text(apr_pool_t *p, const apr_xml_elem *elem,
00286                                   int style, apr_array_header_t *namespaces,
00287                                   int *ns_map, const char **pbuf,
00288                                   apr_size_t *psize);
00289 
00290 
00291 #define APR_XML_X2T_FULL         0      
00292 #define APR_XML_X2T_INNER        1      
00293 #define APR_XML_X2T_LANG_INNER   2      
00294 #define APR_XML_X2T_FULL_NS_LANG 3      
00302 APU_DECLARE(const char *) apr_xml_empty_elem(apr_pool_t *p,
00303                                              const apr_xml_elem *elem);
00304 
00315 APU_DECLARE(const char *) apr_xml_quote_string(apr_pool_t *p, const char *s,
00316                                                int quotes);
00317 
00323 APU_DECLARE(void) apr_xml_quote_elem(apr_pool_t *p, apr_xml_elem *elem);
00324 
00325 
00326 
00333 APU_DECLARE(int) apr_xml_insert_uri(apr_array_header_t *uri_array,
00334                                     const char *uri);
00335 
00337 #define APR_XML_GET_URI_ITEM(ary, i) (((const char * const *)(ary)->elts)[i])
00338 
00339 #if APR_CHARSET_EBCDIC
00340 
00347 APU_DECLARE(apr_status_t) apr_xml_parser_convert_doc(apr_pool_t *p,
00348                                                      apr_xml_doc *pdoc,
00349                                                      apr_xlate_t *convset);
00350 #endif
00351 
00352 #ifdef __cplusplus
00353 }
00354 #endif
00355 
00356 #endif