parser.c File Reference

#include "xsb_config.h"
#include "dtd.h"
#include "parser.h"
#include "model.h"
#include "sgmldefs.h"
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include "utf8.h"
#include "utf8.c"
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include "util.h"
#include "error_term.h"
#include "cinterf.h"

Data Structures

struct  locbuf
struct  namelist

Defines

#define DTD_IMPLEMENTATION   1
#define MAXSTRLEN   256
#define HasClass(dtd, chr, mask)   (dtd->charclass->class[(chr)] & (mask))
#define WITH_PARSER(p, g)
#define WITH_CLASS(p, c, g)
#define sgml_cplocation(d, s)   _sgml_cplocation(d, s)
#define isDirSep(c)   ((c) == '/')
#define DIRSEPSTR   "/"
#define EOS   '\0'
#define streq(s1, s2)   (strcmp(s1, s2) == 0)

Typedefs

typedef locbuf locbuf

Enumerations

enum  includetype { IE_NORMAL, IE_INCLUDED, IE_EXCLUDED }

Functions

static void empty_cdata (dtd_parser *p)
int parse_url (const char *url, char *server, char *fname)
int get_file_www (char *server, char *fname, char **buf)
static int match_shortref (dtd_parser *p)
static int prepare_cdata (dtd_parser *p)
static int process_declaration (dtd_parser *p, const ichar *decl)
static int process_begin_element (dtd_parser *p, const ichar *decl)
static const icharitake_name (dtd *dtd, const ichar *in, dtd_symbol **id)
static const ichariskip_layout (dtd *dtd, const ichar *in)
static dtd_elementfind_element (dtd *dtd, dtd_symbol *id)
static dtd_elementdef_element (dtd *dtd, dtd_symbol *id)
static int open_element (dtd_parser *p, dtd_element *e, int warn)
static sgml_environmentpush_element (dtd_parser *p, dtd_element *e, int callback)
void sgml_cplocation (dtd_srcloc *d, dtd_srcloc *loc)
static const icharisee_func (dtd *dtd, const ichar *in, charfunc func)
static const icharprocess_attributes (dtd_parser *p, dtd_element *e, const ichar *decl, sgml_attribute *atts, int *argc)
static void allow_for (dtd_element *in, dtd_element *e)
static ichar const * get_attribute_value (dtd_parser *p, ichar const *decl, sgml_attribute *att)
static const icharitake_nmtoken (dtd *dtd, const ichar *in, dtd_symbol **id)
static dtd_attrfind_attribute (dtd_element *e, dtd_symbol *name)
static int add_default_attributes (dtd_parser *p, dtd_element *e, int natts, sgml_attribute *atts)
static void set_element_properties (dtd_element *e, dtd_attr *a)
static void free_attribute_values (int argc, sgml_attribute *argv)
static void free_attribute (dtd_attr *a)
static const icharitake_string (dtd *dtd, const ichar *in, ichar *out, int len)
static void add_submodel (dtd_model *m, dtd_model *sub)
static void free_environment (sgml_environment *env)
static void validate_completeness (sgml_environment *env)
static int emit_cdata (dtd_parser *p, int last)
static int complete (sgml_environment *env)
static void push_location (dtd_parser *p, locbuf *save)
static void pop_location (dtd_parser *p, locbuf *saved)
static void inc_location (dtd_srcloc *l, int chr)
static void dec_location (dtd_srcloc *l, int chr)
static __inline void _sgml_cplocation (dtd_srcloc *d, dtd_srcloc *loc)
static int close_element (dtd_parser *p, dtd_element *e, int conref)
static int process_entity (dtd_parser *p, const ichar *name)
static int process_entity_declaration (dtd_parser *p, const ichar *decl)
static dtd_symboldtd_find_entity_symbol (dtd *dtd, const ichar *name)
static const icharisee_identifier (dtd *dtd, const ichar *in, char *id)
static const icharitake_entity_name (dtd *dtd, const ichar *in, dtd_symbol **id)
static icharbaseurl (dtd_parser *p)
static dtd_entityfind_pentity (dtd *dtd, dtd_symbol *id)
void set_src_dtd_parser (dtd_parser *p, input_type type, const char *name)
static const icharprocess_entity_value_declaration (dtd_parser *p, const ichar *decl, dtd_entity *e)
static dtd_symbol_tablenew_symbol_table ()
static int expand_pentities (dtd_parser *p, const ichar *in, ichar *out, int len)
static const icharentity_value (dtd_parser *p, dtd_entity *e, int *len)
static const icharisee_character_entity (dtd *dtd, const ichar *in, int *chr)
static int char_entity_value (const ichar *decl)
int sgml_process_file (dtd_parser *p, const char *file, unsigned flags)
static int process_cdata (dtd_parser *p, int last)
int end_document_dtd_parser_ (dtd_parser *p)
int end_document_dtd_parser (dtd_parser *p)
int sgml_process_stream (dtd_parser *p, char *buf, unsigned flags, int source_len)
static const icharitake_url (dtd *dtd, const ichar *in, ichar **out)
static int pop_to (dtd_parser *p, sgml_environment *to, dtd_element *e0)
static const char * entity_file (dtd *dtd, dtd_entity *e)
static int representable_char (dtd_parser *p, int chr)
static int process_net (dtd_parser *p)
static void update_space_mode (dtd_parser *p, dtd_element *e, int natts, sgml_attribute *atts)
static dtd_space_mode istr_to_space_mode (const ichar *val)
static int process_element_declaraction (dtd_parser *p, const ichar *decl)
static int process_doctype (dtd_parser *p, const ichar *decl, const ichar *decl0)
static const icharitake_el_or_model_element_list (dtd *dtd, const ichar *decl, dtd_symbol **names, int *n)
static dtd_modelmake_model (dtd *dtd, const ichar *decl, const ichar **end)
static void free_elements (dtd_element *e)
static void free_element_definition (dtd_edef *def)
static void free_model (dtd_model *m)
static void free_element_list (dtd_element_list *l)
static void for_elements_in_model (dtd_model *m, void(*f)(dtd_element *e, void *closure), void *closure)
static void add_list_element (dtd_element *e, void *closure)
static const icharprocess_model (dtd *dtd, dtd_edef *e, const ichar *decl)
static const icharitake_namegroup (dtd *dtd, charfunc sep, const ichar *decl, dtd_symbol **names, int *n)
static void add_element_list (dtd_element_list **l, dtd_element *e)
static void free_attribute_list (dtd_attr_list *l)
static void process_marked_section (dtd_parser *p)
static void free_name_list (dtd_name_list *nl)
static void recover_parser (dtd_parser *p)
static int close_current_element (dtd_parser *p)
static dtd_parserclone_dtd_parser (dtd_parser *p)
void reset_document_dtd_parser (dtd_parser *p)
static const icharitake_nmtoken_chars (dtd *dtd, const ichar *in, ichar *out, int len)
static int process_attlist_declaraction (dtd_parser *p, const ichar *decl)
static int process_pi (dtd_parser *p, const ichar *decl)
static int match_map (dtd *dtd, dtd_map *map, int len, ichar *data)
static void add_name_list (dtd_name_list **nl, dtd_symbol *s)
static includetype in_or_excluded (sgml_environment *env, dtd_element *e)
static void pop_marked_section (dtd_parser *p)
static const icharisee_ngsep (dtd *dtd, const ichar *decl, charfunc *sep)
static const icharitake_nutoken (dtd *dtd, const ichar *in, dtd_symbol **id)
static const icharitake_number (dtd *dtd, const ichar *in, dtd_attr *at)
static void add_verbatim_cdata (dtd_parser *p, int chr)
static void set_encoding (dtd_parser *p, const ichar *enc)
static void init_decoding (dtd_parser *p)
static int process_notation_declaration (dtd_parser *p, const ichar *decl)
static dtd_notationfind_notation (dtd *dtd, dtd_symbol *name)
static const icharitake_dubbed_string (dtd *dtd, const ichar *in, ichar **out)
static int process_end_element (dtd_parser *p, const ichar *decl)
static void add_notation (dtd *dtd, dtd_notation *not)
static int process_chars (dtd_parser *p, input_type in, const ichar *name, const ichar *s)
static int process_include (dtd_parser *p, const ichar *entity_name)
static dtd_shortrefdef_shortref (dtd_parser *p, dtd_symbol *name)
static int process_shortref_declaration (dtd_parser *p, const ichar *decl)
static const icharshortref_add_map (dtd *dtd, const ichar *decl, dtd_shortref *sr)
static void compile_map (dtd *dtd, dtd_shortref *sr)
static int process_usemap_declaration (dtd_parser *p, const ichar *decl)
static dtd_shortreffind_map (dtd *dtd, dtd_symbol *name)
static void set_map_element (dtd_element *e, void *closure)
static int expand_entities (dtd_parser *p, const ichar *in, ochar *out, int len)
static ichar const * itake_unquoted (dtd *dtd, ichar const *in, ichar *out, int len)
void free_dtd_parser (dtd_parser *p)
void free_dtd (dtd *dtd)
static void free_entity_list (dtd_entity *e)
static void free_notations (dtd_notation *n)
static void free_shortrefs (dtd_shortref *sr)
static void free_maps (dtd_map *map)
static void free_symbol_table (dtd_symbol_table *t)
int is_absolute_path (const char *name)
static void process_utf8 (dtd_parser *p, int chr)
char * localpath (const char *ref, const char *name)
static char * DirName (const char *f, char *dir)
static char * format_location (char *s, dtd_srcloc *l)
static void format_message (dtd_error *e)
int gripe (dtd_error_id e,...)
static int set_option_dtd (dtd *dtd, dtd_option option, char *set)
void set_mode_dtd_parser (dtd_parser *p, data_mode m)
static __inline void setlocation (dtd_srcloc *d, dtd_srcloc *loc, int line, int lpos)
int set_dialect_dtd (dtd *dtd, dtd_dialect dialect)
static void add_cdata (dtd_parser *p, int chr)
void putchar_dtd_parser (dtd_parser *p, int chr)
static void add_attribute (dtd *dtd, dtd_element *e, dtd_attr *a)
int load_dtd_from_file (dtd_parser *p, const char *file)
dtd_symboldtd_add_symbol (dtd *dtd, const ichar *name)

Variables

static dtd_parsercurrent_parser
static char * xml_entities []

Define Documentation

#define DIRSEPSTR   "/"
 

#define DTD_IMPLEMENTATION   1
 

#define EOS   '\0'
 

#define HasClass dtd,
chr,
mask   )     (dtd->charclass->class[(chr)] & (mask))
 

#define isDirSep  )     ((c) == '/')
 

#define MAXSTRLEN   256
 

#define sgml_cplocation d,
 )     _sgml_cplocation(d, s)
 

#define streq s1,
s2   )     (strcmp(s1, s2) == 0)
 

#define WITH_CLASS p,
c,
g   ) 
 

Value:

{ sgml_event_class _oc = p->event_class;        \
    p->event_class = c;                         \
    g;                                          \
    p->event_class = _oc;                       \
  }

#define WITH_PARSER p,
g   ) 
 

Value:

{ dtd_parser *_old = p;                 \
    current_parser = p;                         \
    g;                                          \
    current_parser = _old;                      \
  }


Typedef Documentation

typedef struct locbuf locbuf
 


Enumeration Type Documentation

enum includetype
 

Enumerator:
IE_NORMAL 
IE_INCLUDED 
IE_EXCLUDED 


Function Documentation

static __inline void _sgml_cplocation dtd_srcloc d,
dtd_srcloc loc
[static]
 

Set the parsing location Input : pointer to location object Output : none

static void add_attribute dtd dtd,
dtd_element e,
dtd_attr a
[static]
 

Function to add the attribute list to the output element. It also validates the xml element according to the dtd. Input : dtd object pointer, element, attribute list Output : none

static void add_cdata dtd_parser p,
int  chr
[static]
 

Add a newly read character to the parser cdata memory buffer. This memory buffer will be used to create the output terms Input : parser object pointer, newly read character Output : none

static int add_default_attributes dtd_parser p,
dtd_element e,
int  natts,
sgml_attribute atts
[static]
 

Add default attribute to xml element Input : pointer to parser object, xml element object pointer, attributes Output : Number of attributes

static void add_element_list dtd_element_list **  l,
dtd_element e
[static]
 

Add a dtd element to a list Input : element list, element to be added

static void add_list_element dtd_element e,
void *  closure
[static]
 

Internal swi parser functions to process the xml elements, attributes and create the output terms

static void add_name_list dtd_name_list **  nl,
dtd_symbol s
[static]
 

Internal SWI function which aids in parsing attlist declaration

static void add_notation dtd dtd,
dtd_notation not
[static]
 

Add the newly parsed notation to the table of notations Input : dtd object pointer, notation declaration Output : none

static void add_submodel dtd_model m,
dtd_model sub
[static]
 

static void add_verbatim_cdata dtd_parser p,
int  chr
[static]
 

Function to add verbatim cdata to the parser buffers Input : parser object pointer, verbatim cdata character Output : none

static void allow_for dtd_element in,
dtd_element e
[static]
 

Internal SWI function which aids in opening an element i.e processing the opening tag of an element

static ichar * baseurl dtd_parser p  )  [static]
 

Return the baseurl of the dtd

static int char_entity_value const ichar decl  )  [static]
 

Helper functions to aid in extracting the entity value

static dtd_parser * clone_dtd_parser dtd_parser p  )  [static]
 

Create a copy of the parser Input : parser object pointer Output : pointer to copy of parser object

clone = *p;

static int close_current_element dtd_parser p  )  [static]
 

Close the current element whose environment is open Input : parser object pointer Output : TRUE on success/ FALSE on failure

static int close_element dtd_parser p,
dtd_element e,
int  conref
[static]
 

Close an open element. Perform cleanup operations when closing element tag is encountered. Input : parser object pointer, closing element Output : TRUE on success/ FALSE on failure

static void compile_map dtd dtd,
dtd_shortref sr
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create an array with TRUE in any character that can be the last of the shortref map.
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : dtd object pointer, shortref declaration Output : none

static int complete sgml_environment env  )  [static]
 

static void dec_location dtd_srcloc l,
int  chr
[static]
 

Decrement current parser location

static dtd_element * def_element dtd dtd,
dtd_symbol id
[static]
 

Allocate default element structure. Input : pointer to dtd object, symbol table entry Output : created dtd element

static dtd_shortref * def_shortref dtd_parser p,
dtd_symbol name
[static]
 

static char * DirName const char *  f,
char *  dir
[static]
 

Convert path handling different directory separators

dtd_symbol* dtd_add_symbol dtd dtd,
const ichar name
 

Add specified symbol to dtd symbol table Input : pointer to dtd object, symbol name string Output : added dtd symbol table entry

static dtd_symbol * dtd_find_entity_symbol dtd dtd,
const ichar name
[static]
 

Search for entity symbol in the entity symbol table Input : dtd object pointer, entity symbol Output: the entity entry in the symbol table

static int emit_cdata dtd_parser p,
int  last
[static]
 

Handle the cdata in the parser buffer

static void empty_cdata dtd_parser p  )  [static]
 

Empty the parser cdata buffer Input : pointer to parser object Output : none

int end_document_dtd_parser dtd_parser p  ) 
 

Wrapper for end_document_dtd_parser

int end_document_dtd_parser_ dtd_parser p  ) 
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deal with end of input. We should give a proper error message depending on the state and the start-location of the error.
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : parser object pointer Output : none

static const char * entity_file dtd dtd,
dtd_entity e
[static]
 

Extract the filename which holds the entity value Input : pointer to dtd object, pointer to entity object Output : Extracted filename

static const ichar * entity_value dtd_parser p,
dtd_entity e,
int len
[static]
 

static int expand_entities dtd_parser p,
const ichar in,
ochar out,
int  len
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Expand entities in a string. Used to expand CDATA attribute values.
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

static int expand_pentities dtd_parser p,
const ichar in,
ichar out,
int  len
[static]
 

Function to expand the occurence of entities according to the dtd Input : pointer to parser object, declaration Output : expanded entity, TRUE on success/ FALSE on failure

static dtd_attr * find_attribute dtd_element e,
dtd_symbol name
[static]
 

Find attribute in attributes of xml element Input : xml element, symbol to find Output : attribute found in xml element, NULL if absent

static dtd_element * find_element dtd dtd,
dtd_symbol id
[static]
 

Find specified element in dtd symbol table Input : pointer to dtd object, symbol table entry of symbol to find Output : pointer to correspoding element

static dtd_shortref * find_map dtd dtd,
dtd_symbol name
[static]
 

static dtd_notation * find_notation dtd dtd,
dtd_symbol name
[static]
 

Look for specified notation in the dtd notation table Input : dtd object pointer, specified notation Output : pointer to notation object

static dtd_entity * find_pentity dtd dtd,
dtd_symbol id
[static]
 

Find the pentity in the dtd symbol table Input : pointer to dtd object, entity to find Output : The pointer to entity found

static void for_elements_in_model dtd_model m,
void(*)(dtd_element *e, void *closure)  f,
void *  closure
[static]
 

for_elements_in_model() Walk along the model, calling f(e, closure) for any element found in the model. Used for <!SHORTREF name model>

static char * format_location char *  s,
dtd_srcloc l
[static]
 

Helper function to format the error message. The function formats the location (line, char) of the error. Input : location of error Output : formatted message

static void format_message dtd_error e  )  [static]
 

Function to format the error/warning message to be thrown. Converts the error codes to actual messages. Input : error Output : none

static void free_attribute dtd_attr a  )  [static]
 

static void free_attribute_list dtd_attr_list l  )  [static]
 

Function to free the attribute list

static void free_attribute_values int  argc,
sgml_attribute argv
[static]
 

Free the attribute values. Helper function is processing the beginning of xml element

void free_dtd dtd dtd  ) 
 

Function to free the dtd object

void free_dtd_parser dtd_parser p  ) 
 

Function to free the parser object

static void free_element_definition dtd_edef def  )  [static]
 

Function to free the element definition

static void free_element_list dtd_element_list l  )  [static]
 

Function to free the element list

static void free_elements dtd_element e  )  [static]
 

Function to free elements

static void free_entity_list dtd_entity e  )  [static]
 

Function to free the entity list

static void free_environment sgml_environment env  )  [static]
 

Free the xml element environment Input : xml environment Output : none

static void free_maps dtd_map map  )  [static]
 

Function to free the maps

static void free_model dtd_model m  )  [static]
 

Function to free the state engine

static void free_name_list dtd_name_list nl  )  [static]
 

static void free_notations dtd_notation n  )  [static]
 

Function to free the notations list

static void free_shortrefs dtd_shortref sr  )  [static]
 

Function to free the shortref list

static void free_symbol_table dtd_symbol_table t  )  [static]
 

Function to free the dtd symbol table

static ichar const * get_attribute_value dtd_parser p,
ichar const *  decl,
sgml_attribute att
[static]
 

Extract the attribute value while processing the attributes of xml element while processing the xml source Input : pointer to parser object, xml source Output : remaining xml source, the pointer to attribute object created after it is extracted

int get_file_www char *  server,
char *  fname,
char **  buf
 

int gripe dtd_error_id  e,
  ...
 

Error handling function. This is the function that gets called when a parsin error is encountered. It creates the error term in the allocated global erro term. Input : error Output : TRUE on success/ FALSE on failure

static includetype in_or_excluded sgml_environment env,
dtd_element e
[static]
 

static void inc_location dtd_srcloc l,
int  chr
[static]
 

Increment current parser location

static void init_decoding dtd_parser p  )  [static]
 

Helper functions to aid in setting the encoding of parser

int is_absolute_path const char *  name  ) 
 

Check if the path is absolute or relative Input : path Output : TRUE if path is absolute/ FALSE otherwise

static const ichar * isee_character_entity dtd dtd,
const ichar in,
int chr
[static]
 

Extract the character entity from the declaration if present Input : pointer to dtd object, declaration, character to extract Output : remaining declaration

static const ichar * isee_func dtd dtd,
const ichar in,
charfunc  func
[static]
 

Extract the specified charfunc from the xml source stream if present Input : pointer to dtd object, xml source stream, specified charfunc Output : remaining xml source stream

static const ichar * isee_identifier dtd dtd,
const ichar in,
char *  id
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - See whether we are looking at identifier "id". "id" must be lowercase! This is only used for reserved words, and parsed case-insentive in both XML and SGML modes.
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : pointer to dtd object, input source stream Output : remaining stream

static const ichar * isee_ngsep dtd dtd,
const ichar decl,
charfunc sep
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - See a name-group separator. As long as we haven't decided, this can be CF_NG. If we have decided they must all be the same.
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : dtd object pointer, attlist declaration, separator = CF_NG Output : remaining attlist declaration

static const ichar * iskip_layout dtd dtd,
const ichar in
[static]
 

Skip comments and whitespaces Input : pointer to dtd object, xml source stream Output : remaining xml stream

static dtd_space_mode istr_to_space_mode const ichar val  )  [static]
 

Return the code for space handling string Input : String specifying the space handling method Output : Code specifying space handling

static const ichar * itake_dubbed_string dtd dtd,
const ichar in,
ichar **  out
[static]
 

static const ichar * itake_el_or_model_element_list dtd dtd,
const ichar decl,
dtd_symbol **  names,
int n
[static]
 

Internal SWI function to process the model (state engine) which parses the xml.

static const ichar * itake_entity_name dtd dtd,
const ichar in,
dtd_symbol **  id
[static]
 

Extract the entity name from the source string if present Input : pointer to dtd object, input source stream Output : remaining source stream, the symbol table entry created for the entity extracted.

static const ichar * itake_name dtd dtd,
const ichar in,
dtd_symbol **  id
[static]
 

Extract the specified name from the xml source if present Input : pointer to dtd object, xml source , symbol to extract Output : remaining xml source

static const ichar * itake_namegroup dtd dtd,
charfunc  sep,
const ichar decl,
dtd_symbol **  names,
int n
[static]
 

Function to extract the namegroup from the declaration if present Input : Pointer to dtd object, separating char, declaration Output : remaining declaration, pointer to symbol table object created after the namegroup is parsed.

static const ichar * itake_nmtoken dtd dtd,
const ichar in,
dtd_symbol **  id
[static]
 

Extracts the nmtoken from the attlist declaration Input : dtd object pointer, attlist declaration Output : remaining declaration, symbol table entry created after the nmtoken is extracted.

static const ichar * itake_nmtoken_chars dtd dtd,
const ichar in,
ichar out,
int  len
[static]
 

Helper function which extracts the nmtoken characters in processing instructions and attlist declarations.

static const ichar * itake_number dtd dtd,
const ichar in,
dtd_attr at
[static]
 

Extract the number type of attribute from declaration. Input : pointer to dtd object, attlist declaration Output : The remaining declaration, dtd symbol created after parsing number

static const ichar * itake_nutoken dtd dtd,
const ichar in,
dtd_symbol **  id
[static]
 

Extract the nutoken type of attribute from declaration. Input : pointer to dtd object, attlist declaration Output : The remaining declaration, dtd symbol created after parsing nutoken

static const ichar * itake_string dtd dtd,
const ichar in,
ichar out,
int  len
[static]
 

Extract the string from the xml source stream Input : pointer to dtd object, xml source stream Output : Extracted string, remaining xml stream

static ichar const * itake_unquoted dtd dtd,
ichar const *  in,
ichar out,
int  len
[static]
 

Extract the unquoted string from stream Input : pointer to dtd object, input stream, Output : extracted unquoted string, length

static const ichar * itake_url dtd dtd,
const ichar in,
ichar **  out
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - itake_url() is used to get the argument of a SYSTEM or 2nd argument of a PUBLIC reference. Once upon a time it tried to tag the argument as file:<path>, but this job cannot be before lookup in the catalogue. We could have replaced the calls with itake_string(), but I'll leave it this way for documentation purposes.
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

int load_dtd_from_file dtd_parser p,
const char *  file
 

Load the dtd from a file either local or remote Input : pointer to parser object, file path Output : TRUE on success/ FALSE on failure

char* localpath const char *  ref,
const char *  name
 

Return the local path of the file specified

static dtd_model * make_model dtd dtd,
const ichar decl,
const ichar **  end
[static]
 

Internal SWI function to process the state engine

static int match_map dtd dtd,
dtd_map map,
int  len,
ichar data
[static]
 

Internal SWI functions which aid in parsing shortrefs in xml document

static int match_shortref dtd_parser p  )  [static]
 

static dtd_symbol_table * new_symbol_table  )  [static]
 

Create a new symbol table Input : none Output : symbol table

static int open_element dtd_parser p,
dtd_element e,
int  warn
[static]
 

Open an xml element. Called when the opening tag of xml is encountered. Input : pointer to parser object, opened element Output : TRUE on success/ FALSE on failure

int parse_url const char *  url,
char *  server,
char *  fname
 

static void pop_location dtd_parser p,
locbuf saved
[static]
 

Pop location from saved buffer Input : pointer to parser object, saved location buffer Output : none

static void pop_marked_section dtd_parser p  )  [static]
 

Internal SWI functions to process marked sections in the xml document

static int pop_to dtd_parser p,
sgml_environment to,
dtd_element e0
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pop the stack, closing all environment uptil `to'. The close was initiated by pushing the element `e'.
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : parser object pointer, environment, xml element Output : TRUE on success/ FALSE on failure

static int prepare_cdata dtd_parser p  )  [static]
 

Function for handling the cdata in the parser buffer before processing entities, declarations, short declarations etc. Input : parser object pointer Output : TRUE on success/ FALSE on failure

static int process_attlist_declaraction dtd_parser p,
const ichar decl
[static]
 

Process ATTLIST declaration in dtd Input : pointer to parser object, attlist declaration Output : TRUE on success/ FALSE on failure

static const ichar * process_attributes dtd_parser p,
dtd_element e,
const ichar decl,
sgml_attribute atts,
int argc
[static]
 

Process the attributes in an xml element Input : pointer to parser object, corresponding element, element declaration attributes Output : remaining xml source

static int process_begin_element dtd_parser p,
const ichar decl
[static]
 

Process the beginning xml tag of an xml element Input : pointer to parser object, xml source Output : TRUE on success/ FALSE on failure

static int process_cdata dtd_parser p,
int  last
[static]
 

static int process_chars dtd_parser p,
input_type  in,
const ichar name,
const ichar s
[static]
 

Helper function to process entity declaration

static int process_declaration dtd_parser p,
const ichar decl
[static]
 

Process a declaration...<...> Input : parser object pointer, declaration Output : TRUE on success/ FALSE on failure

static int process_doctype dtd_parser p,
const ichar decl,
const ichar decl0
[static]
 

Process the doctype declaration <!DOCTYPE...> Input : pointer to parser object, doctype declaration Output : TRUE on success/ FALSE on failure

static int process_element_declaraction dtd_parser p,
const ichar decl
[static]
 

Process xml element declaration. Input : pointer to parser object, element declaration Output : TRUE on success/ FALSE on failure

static int process_end_element dtd_parser p,
const ichar decl
[static]
 

Processing the closing tag of an xml element Input : parser object pointer, closing element Output : TRUE on success/ FALSE on failure

static int process_entity dtd_parser p,
const ichar name
[static]
 

Process entity declaration. <!ENTITY...> Input : parser object pointer, entity Output : TRUE on success/ FALSE on failure

static int process_entity_declaration dtd_parser p,
const ichar decl
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The sgml-standard tells us to accept the first definition of an entity, silently suppressing any further attempt to redefine the entity.
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : pointer to parser object, entity declaration Output: TRUE on success/ FALSE on failure

static const ichar * process_entity_value_declaration dtd_parser p,
const ichar decl,
dtd_entity e
[static]
 

Process the value of the entity declaration Input : pointer to parser object, entity declaration, entity Output : remaining declaration

static int process_include dtd_parser p,
const ichar entity_name
[static]
 

Function to parse the parameter entity declaration Input : parser object pointer, entity declaration Output : TRUE on success/ FALSE on failure

static void process_marked_section dtd_parser p  )  [static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Process <![ KEYWORD [

Switches ->mark_state according to KEYWORD. Processes the rest in normal S_PCDATA style, which pops the mark-stack on seeing ]]>

For the purpose of <!DOCTYPE spec [additions]> we switch to S_GROUP if

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : parser object pointer Output : none

static const ichar * process_model dtd dtd,
dtd_edef e,
const ichar decl
[static]
 

Functions to process the state engine which is created to parse the xml.

static int process_net dtd_parser p  )  [static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - process_net(dtd_parser *p) We've seen a / of a shorttag element. Close this one.
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : parser object pointer Output : TRUE on success/ FALSE on failure

static int process_notation_declaration dtd_parser p,
const ichar decl
[static]
 

Process notation declaration. Input : parser object pointer, notation declaration Output : TRUE on success/ FALSE on failure

static int process_pi dtd_parser p,
const ichar decl
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Process <? ... ?>

Should deal with character encoding for XML documents.

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : parser object pointer, the <?...?> declaration Output : TRUE on success/ FALSE on failure

static int process_shortref_declaration dtd_parser p,
const ichar decl
[static]
 

Process the shortref declaration Input : parser object pointer, shortref declaration Output : TRUE on success/ FALSE on failure

static int process_usemap_declaration dtd_parser p,
const ichar decl
[static]
 

Processing the usemap declaration Input : parser object pointer, usemap declaration Output : TRUE on success/ FALSE on failure

static void process_utf8 dtd_parser p,
int  chr
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set the UTF-8 state
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

static sgml_environment * push_element dtd_parser p,
dtd_element e,
int  callback
[static]
 

Push the xml element environment on stack Input : pointer to parser object, xml element Output : pushed environment

static void push_location dtd_parser p,
locbuf save
[static]
 

Save the parsing location Input : pointer to parser object, location saving buffer pointer Output : none

void putchar_dtd_parser dtd_parser p,
int  chr
 

This is the main parsing function which is invoked to parse the xml when the input source is read character by character. Input : parser object pointer, newly read character Output : none

static void recover_parser dtd_parser p  )  [static]
 

We discovered illegal markup and now process it as normal CDATA Input : parser object pointer Output : none

static int representable_char dtd_parser p,
int  chr
[static]
 

Can we represent this character in a normal CDATA string?

void reset_document_dtd_parser dtd_parser p  ) 
 

Reset the parser which ensures a clean start of parsing Input : parser object pointer Output : none

int set_dialect_dtd dtd dtd,
dtd_dialect  dialect
 

Set the xml dialect in dtd. The dialect may be XML, XMLNS, SGML Input : The dtd object pointer, xml dialect Output : none

static void set_element_properties dtd_element e,
dtd_attr a
[static]
 

Set properties of an xml element Input : xml element, attributes Output : none

static void set_encoding dtd_parser p,
const ichar enc
[static]
 

Set character encoding in the parser Input : parser object pointer, encoding Output : none

static void set_map_element dtd_element e,
void *  closure
[static]
 

void set_mode_dtd_parser dtd_parser p,
data_mode  m
 

Sets the parsing mode of parser. Mode may be dtd mode or xml data mode Input : parser object pointer, mode Output : none

static int set_option_dtd dtd dtd,
dtd_option  option,
char *  set
[static]
 

Sets the dtd shorttag handling capabilities of the parser Input : dtd parser, option, whether to set it FALSE or TRUE Output : None

void set_src_dtd_parser dtd_parser p,
input_type  type,
const char *  name
 

Set the xml source in the parser Input : pointer to parser object, input type, name of source Output : void

static __inline void setlocation dtd_srcloc d,
dtd_srcloc loc,
int  line,
int  lpos
[static]
 

Sets the current parsing location Input : Dtd object pointer, location Output : none

void sgml_cplocation dtd_srcloc d,
dtd_srcloc loc
 

int sgml_process_file dtd_parser p,
const char *  file,
unsigned  flags
 

Helper function to download the files which contain entity declarations.

int sgml_process_stream dtd_parser p,
char *  buf,
unsigned  flags,
int  source_len
 

Helper function to download remote files which contain entity declarations.

static const ichar * shortref_add_map dtd dtd,
const ichar decl,
dtd_shortref sr
[static]
 

Internal SWI prolog functions to process shortref maps

void update_space_mode dtd_parser p,
dtd_element e,
int  natts,
sgml_attribute atts
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Update the space-mode for the current element. The space mode defines how spaces are handled in the CDATA output.
    • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

static void validate_completeness sgml_environment env  )  [static]
 

Function for checking the completeness of an xml element Input : the open environment of the xml element


Variable Documentation

dtd_parser* current_parser [static]
 

char* xml_entities[] [static]
 

Initial value:

  { "lt CDATA \"&#60;\"",                 
    "gt CDATA \"&#62;\"",                 
    "amp CDATA \"&#38;\"",                
    "apos CDATA \"&#39;\"",               
    "quot CDATA \"&#34;\"",               
    NULL
  }
Predefined xml entities


Generated on Wed Jul 26 13:26:56 2006 for XSB by  doxygen 1.4.5