Class EntityParser

Class EntityParser

SYNOPSIS

import xmlproc
class EntityParser
  def __init__(self)
  string __module__ = 'xmlproc'
  def feed(self,new_data)
  def find_reg(self,regexp)
  def get_current_sysid(self)
  def get_index(self,target)
  def get_match(self,regexp)
  def get_pos(self)
  def get_region(self)
  def get_wrapped_match(self,wraps)
  def now_at(self,test_str)
  def open_entity(self,sysID)
  def parseEnd(self)
  def parseStart(self)
  def parse_resource(self,sysID)
  def pop_entity(self)
  def push_entity(self,sysID,contents)
  def read_from(self,fileobj,bufsize=16384)
  def scan_to(self,target)
  def set_application(self,app)
  def set_entity_handler(self,ent)
  def set_error_handler(self,err)
  def set_start_point(self)
  def set_sysid(self,sysID)
  def skip_ws(self)
  def test_reg(self,regexp)
  def test_str(self,test_str)
  def update_pos(self)

DESCRIPTION

A generalized parser for XML entities, whether DTD, documents or even catalog files.

def feed(self,new_data)

Accepts more data from the data source. This method must set self.datasize and correctly update self.pos and self.data.

def find_reg(self,regexp)

Moves self.pos to the first character that matches the regexp.

def get_current_sysid(self)

Returns the sysid of the file we are reading now.

def get_index(self,target)

Finds the position where target starts and returns it.

def get_match(self,regexp)

Returns the result of matching the regexp and advances self.pos.

def get_pos(self)

Returns a tuple (line,col).

def get_region(self)

Returns the area from start_point to current position and remove start_point.

def get_wrapped_match(self,wraps)

Returns a contained match. Useful for regexps inside quotes.

def now_at(self,test_str)

Checks if we are at this string now, and if so skips over it.

def open_entity(self,sysID)

Starts parsing a new entity, pushing the old onto the stack. This method must not be used to start parsing, use parse_resource for that.

def parseEnd(self)

Called when there are no more data to notify subclasses.

def parseStart(self)

Called before the parse starts to notify subclasses.

def parse_resource(self,sysID)

Begin parsing an XML entity with the specified public and system identifiers (the system identifier, a URI, is required). Only used to start parsing, not to handle subentities, which open_entity takes care of.

def pop_entity(self)

Skips out of the current entity and back to the previous one.

def push_entity(self,sysID,contents)

Parse some text and consider it a new entity, making it possible to return to the original entity later.

def read_from(self,fileobj,bufsize=16384)

Reads data from a file-like object until EOF. Does not close it. WARNING: This method does not call the parseStart/parseEnd methods, since it does not know if it may be called several times. Use parse_resource if you just want to read a file.

def scan_to(self,target)

Moves self.pos to beyond target and returns skipped text.

def set_application(self,app)

Sets the object to send data events to.

def set_entity_handler(self,ent)

Sets the object that resolves entity references.

def set_error_handler(self,err)

Sets the object to send error events to.

def set_start_point(self)

Stores the current position and tells the parser not to forget any of the data beyond this point until get_region is called.

def set_sysid(self,sysID)

Sets the current system identifier. Does not store the old one.

def skip_ws(self)

Skips over any whitespace at this point.

def test_reg(self,regexp)

Checks if we match the regexp.

def test_str(self,test_str)

See if text at current position matches test_str, without moving.

def update_pos(self)

Updates (line,col)-pos by checking processed blocks.

SEE ALSO

xmlproc


Generated by HTMLFormatter at Sat Mar 21 11:51:56 1998