sgml2pl.c File Reference

#include "xsb_config.h"
#include "cinterf.h"
#include <stdlib.h>
#include "dtd.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "fetch_file.c"
#include "parser.c"
#include "charmap.c"
#include "util.c"
#include "xmlns.c"
#include "model.c"
#include "error_term.h"
#include "util.h"
#include "basic_defs.h"
#include <sys/stat.h>
#include "error.c"

Data Structures

struct  _env
struct  _parser_data

Defines

#define PD_MAGIC   0x36472ba1
#define MAX_ERRORS   50
#define MAX_WARNINGS   50
#define MAXSTRLEN   256
#define CHECKERROR
#define CHARSET   MAXSTRLEN

Typedefs

typedef _env env
typedef _parser_data parser_data

Enumerations

enum  errormode { EM_QUIET = 0, EM_PRINT, EM_STYLE }
enum  stopat {
  SA_FILE = 0, SA_INPUT, SA_ELEMENT, SA_CONTENT,
  SA_DECL
}

Functions

dtdnew_dtd (const ichar *doctype)
static int get_dtd (prolog_term t, dtd **dtdp)
dtd_parsernew_dtd_parser (dtd *dtd)
int unify_dtd (prolog_term t, dtd *dtd)
int unify_parser (prolog_term t, dtd_parser *p)
static int on_begin (dtd_parser *p, dtd_element *e, int argc, sgml_attribute *argv)
static int on_end (dtd_parser *p, dtd_element *e)
static int on_entity (dtd_parser *p, dtd_entity *e, int chr)
static int on_pi (dtd_parser *p, const ichar *pi)
static int on_cdata (dtd_parser *p, data_type type, int len, const ochar *data)
static void put_element_name (dtd_parser *p, prolog_term t, dtd_element *e)
static int unify_attribute_list (dtd_parser *p, prolog_term alist, int argc, sgml_attribute *argv)
static parser_datanew_parser_data (dtd_parser *p)
static void put_url (dtd_parser *p, prolog_term t, const ichar *url)
static int on_error (dtd_parser *p, dtd_error *error)
static int on_decl (dtd_parser *p, const ichar *decl)
static void put_attribute_name (dtd_parser *p, prolog_term t, dtd_symbol *nm)
static void put_attribute_value (dtd_parser *p, prolog_term t, sgml_attribute *a)
static icharistrblank (const ichar *s)
static int unify_listval (dtd_parser *p, prolog_term t, attrtype type, int len, const char *text)
static dtd_srclocfile_location (dtd_parser *p, dtd_srcloc *l)
static int can_end_omitted (dtd_parser *p)
static int set_option_dtd (dtd *dtd, dtd_option option, char *set)
DllExport int call_conv pl_new_sgml_parser ()
DllExport int call_conv pl_new_dtd ()
static int get_parser (prolog_term parser, dtd_parser **p)
DllExport int call_conv pl_doctype ()
DllExport int call_conv pl_set_sgml_parser ()
DllExport int call_conv pl_allocate_error_term ()
DllExport int call_conv pl_finalize_warn ()
DllExport int call_conv pl_sgml_parse ()
DllExport int call_conv pl_open_dtd ()
DllExport int call_conv pl_free_sgml_parser ()
DllExport int call_conv pl_free_dtd ()
static int do_quote (prolog_term in, prolog_term quoted, char **map)
DllExport int call_conv pl_xml_quote_attribute ()
DllExport int call_conv pl_xml_quote_cdata ()
DllExport int call_conv pl_xml_name ()

Variables

dtd_parserparser_error = NULL

Define Documentation

#define CHARSET   MAXSTRLEN
 

Functions to handle quoted strings

#define CHECKERROR
 

Value:

if ( pd->errors > pd->max_errors && pd->max_errors >= 0 )               \
    return sgml2pl_error(ERR_LIMIT, "max_errors", (long)pd->max_errors);

#define MAX_ERRORS   50
 

#define MAX_WARNINGS   50
 

#define MAXSTRLEN   256
 

#define PD_MAGIC   0x36472ba1
 


Typedef Documentation

typedef struct _env env
 

typedef struct _parser_data parser_data
 


Enumeration Type Documentation

enum errormode
 

Enumerator:
EM_QUIET 
EM_PRINT 
EM_STYLE 

enum stopat
 

Enumerator:
SA_FILE 
SA_INPUT 
SA_ELEMENT 
SA_CONTENT 
SA_DECL 


Function Documentation

static int can_end_omitted dtd_parser p  )  [static]
 

static int do_quote prolog_term  in,
prolog_term  quoted,
char **  map
[static]
 

static dtd_srcloc * file_location dtd_parser p,
dtd_srcloc l
[static]
 

Internal functions to aid in parsing the xml

static int get_dtd prolog_term  t,
dtd **  dtdp
[static]
 

Extract the C side dtd object pointer from the prolog term Input : Dtd prolog term Output : Dtd object pointer

static int get_parser prolog_term  parser,
dtd_parser **  p
[static]
 

Extract C side parser object pointer from the prolog term Input : parser prolog term Output : Pointer to C side parser object

static ichar * istrblank const ichar s  )  [static]
 

Internal function to check if string is blank Input : string

dtd* new_dtd const ichar doctype  ) 
 

Dtd object constructor for the C side dtd object Input : doctype string Output : Initialized dtd object pointer

dtd_parser* new_dtd_parser dtd dtd  ) 
 

Create a new parser for the specified dtd. This dtd is used to validate the xml document which is parsed by the parser. Input: dtd object Output: Parser object

static parser_data * new_parser_data dtd_parser p  )  [static]
 

Internal function to set the parser internal data Input : parser object pointer

static int on_begin dtd_parser p,
dtd_element e,
int  argc,
sgml_attribute argv
[static]
 

This function is invoked when an xml element is opened Input : parser object pointer, xml element which is opened, options Output : none

static int on_cdata dtd_parser p,
data_type  type,
int  len,
const ochar data
[static]
 

Handler function which is invoked when cdata is encountered Input : parser object pointer, encountered cdata Output : none

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

This function is invoked when a decalaration is encountered Input : Parser object, string containing declaration Output : none

static int on_end dtd_parser p,
dtd_element e
[static]
 

Handler function which is invoked when the end of element is encountered. Input : parser object pointer, the element Output : none

static int on_entity dtd_parser p,
dtd_entity e,
int  chr
[static]
 

Handler function which is invoked when an entity is encountered Input : parser object, entity encountered Output : none

static int on_error dtd_parser p,
dtd_error error
[static]
 

Error handler. This function is called when an error is encountered while parsing Input : Parser object pointer, error string Output : None, unifies the allocated error term with the error

static int on_pi dtd_parser p,
const ichar pi
[static]
 

Handler function which is invoked when a processing instruction is encountered Input : parser object pointer, processing instruction Output : none

DllExport int call_conv pl_allocate_error_term  ) 
 

Allocate error term on C side Input : Prolog variable Output : none

DllExport int call_conv pl_doctype  ) 
 

Create a doctype object on the C side Input : doctype string, parser prolog term Output : prolog doctype term

DllExport int call_conv pl_finalize_warn  ) 
 

Remove uninstantiated terms in the warning list at end Input : Warning term

DllExport int call_conv pl_free_dtd  ) 
 

Free the dtd object Input : dtd object

DllExport int call_conv pl_free_sgml_parser  ) 
 

Free the allocated parser object Input : parser object

DllExport int call_conv pl_new_dtd  ) 
 

Create a new dtd object on the C side and return pointer to prolog Input: prolog var term, Output: pointer to dtd object

DllExport int call_conv pl_new_sgml_parser  ) 
 

Create a new parser object on the C side and return pointer to prolog Input : Var prolog term, Options list Output : Pointer to parser object

DllExport int call_conv pl_open_dtd  ) 
 

Open the Dtd specified. The parser uses this dtd to validate the xml while parsing Input : dtd object pointer, parser object pointer

DllExport int call_conv pl_set_sgml_parser  ) 
 

Set parse options in the parser object Input : parser object, options list

DllExport int call_conv pl_sgml_parse  ) 
 

This is the main starting function. This function parses the input options and invokes the parser. Input : Parser, Options Output : The parsed prolog term

DllExport int call_conv pl_xml_name  ) 
 

DllExport int call_conv pl_xml_quote_attribute  ) 
 

Function to handle quoted attributes

DllExport int call_conv pl_xml_quote_cdata  ) 
 

Function to handle quoted cdata

static void put_attribute_name dtd_parser p,
prolog_term  t,
dtd_symbol nm
[static]
 

Internal function to resolve xml namespaces for attributes

static void put_attribute_value dtd_parser p,
prolog_term  t,
sgml_attribute a
[static]
 

Internal function to create the attribute list

static void put_element_name dtd_parser p,
prolog_term  t,
dtd_element e
[static]
 

Helper functions to create the element(...) term in the output. Also xml namespaces.

static void put_url dtd_parser p,
prolog_term  t,
const ichar url
[static]
 

  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - put_url(dtd_parser *p, term_t t, const ichar *url) Store the url-part of a name-space qualifier in term. We call xml:xmlns(-Canonical, +Full) trying to resolve the specified namespace to an internal canonical namespace.
  • - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Input : pointer to parser object, prolog term, url Output : none

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

static int unify_attribute_list dtd_parser p,
prolog_term  alist,
int  argc,
sgml_attribute argv
[static]
 

Internal functions to create the attribute list in the element(...) term Input : parser object pointer, attribute list, options Output : none

int unify_dtd prolog_term  t,
dtd d
 

Create a representative dtd_struct(...) prolog term for the dtd object Input: Dtd object pointer Output: dtd prolog term

static int unify_listval dtd_parser p,
prolog_term  t,
attrtype  type,
int  len,
const char *  text
[static]
 

int unify_parser prolog_term  t,
dtd_parser p
 

Create a representative sgml_parser(...) prolog term for the parser object Input : Parser object pointer Output : Prolog parser term


Variable Documentation

dtd_parser* parser_error = NULL
 


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