SAX2

SAX2 — SAX2 XML Parsing API with namespaces and base URI support.

Synopsis

typedef             raptor_sax2;
raptor_sax2 *       raptor_new_sax2                     (raptor_world *world,
                                                         raptor_locator *locator,
                                                         void *user_data);
void                raptor_free_sax2                    (raptor_sax2 *sax2);
void                (*raptor_sax2_start_element_handler)
                                                        (void *user_data,
                                                         raptor_xml_element *xml_element);
void                (*raptor_sax2_end_element_handler)  (void *user_data,
                                                         raptor_xml_element *xml_element);
void                (*raptor_sax2_characters_handler)   (void *user_data,
                                                         raptor_xml_element *xml_element,
                                                         const unsigned char *s,
                                                         int len);
void                (*raptor_sax2_cdata_handler)        (void *user_data,
                                                         raptor_xml_element *xml_element,
                                                         const unsigned char *s,
                                                         int len);
void                (*raptor_sax2_comment_handler)      (void *user_data,
                                                         raptor_xml_element *xml_element,
                                                         const unsigned char *s);
void                (*raptor_sax2_unparsed_entity_decl_handler)
                                                        (void *user_data,
                                                         const unsigned char *entityName,
                                                         const unsigned char *base,
                                                         const unsigned char *systemId,
                                                         const unsigned char *publicId,
                                                         const unsigned char *notationName);
int                 (*raptor_sax2_external_entity_ref_handler)
                                                        (void *user_data,
                                                         const unsigned char *context,
                                                         const unsigned char *base,
                                                         const unsigned char *systemId,
                                                         const unsigned char *publicId);
void                raptor_sax2_set_start_element_handler
                                                        (raptor_sax2 *sax2,
                                                         raptor_sax2_start_element_handler handler);
void                raptor_sax2_set_end_element_handler (raptor_sax2 *sax2,
                                                         raptor_sax2_end_element_handler handler);
void                raptor_sax2_set_characters_handler  (raptor_sax2 *sax2,
                                                         raptor_sax2_characters_handler handler);
void                raptor_sax2_set_cdata_handler       (raptor_sax2 *sax2,
                                                         raptor_sax2_cdata_handler handler);
void                raptor_sax2_set_comment_handler     (raptor_sax2 *sax2,
                                                         raptor_sax2_comment_handler handler);
void                raptor_sax2_set_unparsed_entity_decl_handler
                                                        (raptor_sax2 *sax2,
                                                         raptor_sax2_unparsed_entity_decl_handler handler);
void                raptor_sax2_set_external_entity_ref_handler
                                                        (raptor_sax2 *sax2,
                                                         raptor_sax2_external_entity_ref_handler handler);
void                raptor_sax2_set_namespace_handler   (raptor_sax2 *sax2,
                                                         raptor_namespace_handler handler);
void                raptor_sax2_set_uri_filter          (raptor_sax2 *sax2,
                                                         raptor_uri_filter_func filter,
                                                         void *user_data);
void                raptor_sax2_parse_start             (raptor_sax2 *sax2,
                                                         raptor_uri *base_uri);
int                 raptor_sax2_parse_chunk             (raptor_sax2 *sax2,
                                                         const unsigned char *buffer,
                                                         size_t len,
                                                         int is_end);
const unsigned char * raptor_sax2_inscope_xml_language  (raptor_sax2 *sax2);
raptor_uri *        raptor_sax2_inscope_base_uri        (raptor_sax2 *sax2);

Description

A class providing a SAX2 XML parsing API with XML namespaces and XML base support.

Details

raptor_sax2

typedef struct raptor_sax2_s raptor_sax2;

Raptor SAX2 class


raptor_new_sax2 ()

raptor_sax2 *       raptor_new_sax2                     (raptor_world *world,
                                                         raptor_locator *locator,
                                                         void *user_data);

Constructor - Create a new SAX2 with error handlers

world :

raptor world

locator :

raptor locator to use for errors

user_data :

pointer context information to pass to SAX handlers

Returns :

new raptor_sax2 object or NULL on failure

raptor_free_sax2 ()

void                raptor_free_sax2                    (raptor_sax2 *sax2);

Destructor - destroy a SAX2 object

sax2 :

SAX2 object

raptor_sax2_start_element_handler ()

void                (*raptor_sax2_start_element_handler)
                                                        (void *user_data,
                                                         raptor_xml_element *xml_element);

SAX2 start element handler

user_data :

user data

xml_element :

XML element

raptor_sax2_end_element_handler ()

void                (*raptor_sax2_end_element_handler)  (void *user_data,
                                                         raptor_xml_element *xml_element);

SAX2 end element handler

user_data :

user data

xml_element :

XML element

raptor_sax2_characters_handler ()

void                (*raptor_sax2_characters_handler)   (void *user_data,
                                                         raptor_xml_element *xml_element,
                                                         const unsigned char *s,
                                                         int len);

SAX2 characters handler

user_data :

user data

xml_element :

XML element

s :

string

len :

string len

raptor_sax2_cdata_handler ()

void                (*raptor_sax2_cdata_handler)        (void *user_data,
                                                         raptor_xml_element *xml_element,
                                                         const unsigned char *s,
                                                         int len);

SAX2 CDATA section handler

user_data :

user data

xml_element :

XML element

s :

string

len :

string len

raptor_sax2_comment_handler ()

void                (*raptor_sax2_comment_handler)      (void *user_data,
                                                         raptor_xml_element *xml_element,
                                                         const unsigned char *s);

SAX2 XML comment handler

user_data :

user data

xml_element :

XML element

s :

string

raptor_sax2_unparsed_entity_decl_handler ()

void                (*raptor_sax2_unparsed_entity_decl_handler)
                                                        (void *user_data,
                                                         const unsigned char *entityName,
                                                         const unsigned char *base,
                                                         const unsigned char *systemId,
                                                         const unsigned char *publicId,
                                                         const unsigned char *notationName);

SAX2 unparsed entity (NDATA) handler

user_data :

user data

entityName :

entity name

base :

base URI

systemId :

system ID

publicId :

public ID

notationName :

notation name

raptor_sax2_external_entity_ref_handler ()

int                 (*raptor_sax2_external_entity_ref_handler)
                                                        (void *user_data,
                                                         const unsigned char *context,
                                                         const unsigned char *base,
                                                         const unsigned char *systemId,
                                                         const unsigned char *publicId);

SAX2 external entity reference handler

user_data :

user data

context :

context

base :

base URI

systemId :

system ID

publicId :

public ID

Returns :

0 if processing should not continue because of a fatal error in the handling of the external entity.

raptor_sax2_set_start_element_handler ()

void                raptor_sax2_set_start_element_handler
                                                        (raptor_sax2 *sax2,
                                                         raptor_sax2_start_element_handler handler);

Set SAX2 start element handler.

sax2 :

SAX2 object

handler :

start element handler

raptor_sax2_set_end_element_handler ()

void                raptor_sax2_set_end_element_handler (raptor_sax2 *sax2,
                                                         raptor_sax2_end_element_handler handler);

Set SAX2 end element handler.

sax2 :

SAX2 object

handler :

end element handler

raptor_sax2_set_characters_handler ()

void                raptor_sax2_set_characters_handler  (raptor_sax2 *sax2,
                                                         raptor_sax2_characters_handler handler);

Set SAX2 characters handler.

sax2 :

SAX2 object

handler :

characters handler

raptor_sax2_set_cdata_handler ()

void                raptor_sax2_set_cdata_handler       (raptor_sax2 *sax2,
                                                         raptor_sax2_cdata_handler handler);

Set SAX2 CDATA handler.

sax2 :

SAX2 object

handler :

CDATA handler

raptor_sax2_set_comment_handler ()

void                raptor_sax2_set_comment_handler     (raptor_sax2 *sax2,
                                                         raptor_sax2_comment_handler handler);

Set SAX2 XML comment handler.

sax2 :

SAX2 object

handler :

comment handler

raptor_sax2_set_unparsed_entity_decl_handler ()

void                raptor_sax2_set_unparsed_entity_decl_handler
                                                        (raptor_sax2 *sax2,
                                                         raptor_sax2_unparsed_entity_decl_handler handler);

Set SAX2 XML unparsed entity declaration handler.

sax2 :

SAX2 object

handler :

unparsed entity declaration handler

raptor_sax2_set_external_entity_ref_handler ()

void                raptor_sax2_set_external_entity_ref_handler
                                                        (raptor_sax2 *sax2,
                                                         raptor_sax2_external_entity_ref_handler handler);

Set SAX2 XML entity reference handler.

sax2 :

SAX2 object

handler :

entity reference handler

raptor_sax2_set_namespace_handler ()

void                raptor_sax2_set_namespace_handler   (raptor_sax2 *sax2,
                                                         raptor_namespace_handler handler);

Set the XML namespace handler function.

When a prefix/namespace is seen in an XML parser, call the given handler with the prefix string and the raptor_uri namespace URI. Either can be NULL for the default prefix or default namespace.

The handler function does not deal with duplicates so any namespace may be declared multiple times when a namespace is seen in different parts of a document.

sax2 :

raptor_sax2 object

handler :

new namespace callback function

raptor_sax2_set_uri_filter ()

void                raptor_sax2_set_uri_filter          (raptor_sax2 *sax2,
                                                         raptor_uri_filter_func filter,
                                                         void *user_data);

Set URI filter function for SAX2 internal retrievals.

sax2 :

SAX2 object

filter :

URI filter function

user_data :

User data to pass to filter function

raptor_sax2_parse_start ()

void                raptor_sax2_parse_start             (raptor_sax2 *sax2,
                                                         raptor_uri *base_uri);

Start an XML SAX2 parse.

sax2 :

sax2 object

base_uri :

base URI

raptor_sax2_parse_chunk ()

int                 raptor_sax2_parse_chunk             (raptor_sax2 *sax2,
                                                         const unsigned char *buffer,
                                                         size_t len,
                                                         int is_end);

Parse a chunk of XML data generating SAX2 events

sax2 :

sax2 object

buffer :

input buffer

len :

input buffer lenght

is_end :

non-0 if end of data

Returns :

non-0 on failure

raptor_sax2_inscope_xml_language ()

const unsigned char * raptor_sax2_inscope_xml_language  (raptor_sax2 *sax2);

Get the in-scope XML language

The result is a language string which may be "" if xml:lang="" is given. NULL is returned only if there is no xml:lang in any outer scope.

sax2 :

SAX2 object

Returns :

shared pointer to the XML language or NULL if none is in scope.

raptor_sax2_inscope_base_uri ()

raptor_uri *        raptor_sax2_inscope_base_uri        (raptor_sax2 *sax2);

Get the in-scope base URI

sax2 :

SAX2 object

Returns :

the in-scope base URI shared object or NULL if none is in scope.


Navigation: Redland Home Page

Copyright 2000-2014 Dave Beckett