xml2infoset
index
/devel/WWW/2000/10/swap/xml2infoset.py

#   A parser for XML built on the xmllib XML parser.
#   Hacked down from Dan Connolly's RDF parser which is much more complicated!
#   To do:
#         Option of ordered listing with daml list of children  and/or attrs!!
#         Option of replacing ln and ns with rdf:type ns#e_ln and ns#a_ln - see TAG issue (6?)
#         maybe think about some real connection to XPath or infoset models and vocabulary

 
Modules
            
notation3
string
urllib
urlparse
xmllib
 
Classes
            
xmllib.XMLParser
RDFXMLParser
 
class RDFXMLParser(xmllib.XMLParser)
       
   Methods defined here:
__init__(self, sink, thisURI, **kw)
_generate(self, str='')
The string is just a debugging hint really
close(self)
flush(self)
handle_cdata(self, data)
handle_comment(self, data)
handle_data(self, data)
handle_doctype(self, tag, pubid, syslit, data)
handle_proc(self, name, data)
handle_xml(self, encoding, standalone)
load(self, uri, _baseURI='')
pso(self, pred, subj, obj)
psv(self, pred, subj, obj)
syntax_error(self, message)
tag2uri(self, str)
 Generate URI from tagname
unknown_charref(self, ref)
unknown_endtag(self, tag)
unknown_entityref(self, ref)
unknown_starttag(self, tag, attrs)
 Handle start tag. We register none so all are unknown
uriref(self, str)
 Generate uri from uriref in this document

Data and non-method functions defined here:
__doc__ = None
__module__ = 'xml2infoset'
str(object) -> string
 
Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Methods inherited from xmllib.XMLParser:
_XMLParser__fixclass = __fixclass(self, kl)
_XMLParser__fixdict = __fixdict(self, dict)
_XMLParser__fixelements = __fixelements(self)
feed(self, data)
# Interface -- feed some data to the parser.  Call this as
# often as you want, with as little or as much text as you
# want (may include '\n').  (This just saves the text, all the
# processing is done by goahead().)
finish_endtag(self, tag)
# Internal -- finish processing of end tag
finish_starttag(self, tagname, attrdict, method)
# Internal -- finish processing of start tag
goahead(self, end)
# Internal -- handle data as far as reasonable.  May leave state
# and data to be processed by a subsequent call.  If 'end' is
# true, force handling all data as if followed by EOF marker.
handle_charref(self, name)
# Example -- handle character reference, no need to override
handle_endtag(self, tag, method)
# Overridable -- handle end tag
handle_starttag(self, tag, method, attrs)
# Overridable -- handle start tag
parse_attributes(self, tag, i, j)
# Internal -- parse attributes between i and j
parse_cdata(self, i)
# Internal -- handle CDATA tag, return length or -1 if not terminated
parse_comment(self, i)
# Internal -- parse comment, return length or -1 if not terminated
parse_doctype(self, res)
# Internal -- handle DOCTYPE tag, return length or -1 if not terminated
parse_endtag(self, i)
# Internal -- parse endtag
parse_proc(self, i)
# Internal -- handle a processing instruction tag
parse_starttag(self, i)
# Internal -- handle starttag, return length or -1 if not terminated
reset(self)
# Interface -- reset this instance.  Loses all unprocessed data
setliteral(self, *args)
# For derived classes only -- enter literal mode (CDATA)
setnomoretags(self)
# For derived classes only -- enter literal mode (CDATA) till EOF
translate_references(self, data, all=1)
# Interface -- translate references

Data and non-method functions inherited from xmllib.XMLParser:
_XMLParser__accept_missing_endtag_name = 0
int(x[, base]) -> integer
 
Convert a string or number to an integer, if possible.  A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!)  When converting a string, use
the optional base.  It is an error to supply a base when converting a
non-string.
_XMLParser__accept_unquoted_attributes = 0
int(x[, base]) -> integer
 
Convert a string or number to an integer, if possible.  A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!)  When converting a string, use
the optional base.  It is an error to supply a base when converting a
non-string.
_XMLParser__accept_utf8 = 0
int(x[, base]) -> integer
 
Convert a string or number to an integer, if possible.  A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!)  When converting a string, use
the optional base.  It is an error to supply a base when converting a
non-string.
_XMLParser__map_case = 0
int(x[, base]) -> integer
 
Convert a string or number to an integer, if possible.  A floating point
argument will be truncated towards zero (this does not include a string
representation of a floating point number!)  When converting a string, use
the optional base.  It is an error to supply a base when converting a
non-string.
_XMLParser__xml_namespace_attributes = {'ns': None, 'prefix': None, 'src': None}
dict() -> new empty dictionary.
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs.
dict(seq) -> new dictionary initialized as if via:
    d = {}
    for k, v in seq:
        d[k] = v
attributes = {}
dict() -> new empty dictionary.
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs.
dict(seq) -> new dictionary initialized as if via:
    d = {}
    for k, v in seq:
        d[k] = v
elements = {}
dict() -> new empty dictionary.
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs.
dict(seq) -> new dictionary initialized as if via:
    d = {}
    for k, v in seq:
        d[k] = v
entitydefs = {'amp': '&', 'apos': ''', 'gt': '>', 'lt': '<', 'quot': '"'}
dict() -> new empty dictionary.
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs.
dict(seq) -> new dictionary initialized as if via:
    d = {}
    for k, v in seq:
        d[k] = v
 
Functions
            
test(args=None)
 
Data
             DAML_ONT_NS = 'http://www.daml.org/2000/10/daml-ont#'
DPO_NS = 'http://www.daml.org/2001/03/daml+oil#'
LITERAL = 2
List_NS = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
NS = 'http://www.w3.org/2000/10/swap/xml#'
RDF_IS = (0, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#is')
RDF_NS_URI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
RDF_Specification = 'http://www.w3.org/TR/REC-rdf-syntax/'
STATE_DESCRIPTION = 'Description (have subject)'
STATE_LIST = 'within list'
STATE_LITERAL = 'within literal'
STATE_NOT_RDF = 'not RDF'
STATE_NOVALUE = 'no value'
STATE_NO_SUBJECT = 'no context'
STATE_VALUE = 'plain value'
SYMBOL = 0
__file__ = './xml2infoset.py'
__name__ = 'xml2infoset'
chatty = 0