本文整理匯總了Python中handler.ContentHandler方法的典型用法代碼示例。如果您正苦於以下問題:Python handler.ContentHandler方法的具體用法?Python handler.ContentHandler怎麽用?Python handler.ContentHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類handler
的用法示例。
在下文中一共展示了handler.ContentHandler方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _qname
# 需要導入模塊: import handler [as 別名]
# 或者: from handler import ContentHandler [as 別名]
def _qname(self, name):
"""Builds a qualified name from a (ns_url, localname) pair"""
if name[0]:
# Per http://www.w3.org/XML/1998/namespace, The 'xml' prefix is
# bound by definition to http://www.w3.org/XML/1998/namespace. It
# does not need to be declared and will not usually be found in
# self._current_context.
if 'http://www.w3.org/XML/1998/namespace' == name[0]:
return 'xml:' + name[1]
# The name is in a non-empty namespace
prefix = self._current_context[name[0]]
if prefix:
# If it is not the default namespace, prepend the prefix
return prefix + ":" + name[1]
# Return the unqualified name
return name[1]
# ContentHandler methods
示例2: __init__
# 需要導入模塊: import handler [as 別名]
# 或者: from handler import ContentHandler [as 別名]
def __init__(self):
self._cont_handler = handler.ContentHandler()
self._dtd_handler = handler.DTDHandler()
self._ent_handler = handler.EntityResolver()
self._err_handler = handler.ErrorHandler()
示例3: getContentHandler
# 需要導入模塊: import handler [as 別名]
# 或者: from handler import ContentHandler [as 別名]
def getContentHandler(self):
"Returns the current ContentHandler."
return self._cont_handler
示例4: __init__
# 需要導入模塊: import handler [as 別名]
# 或者: from handler import ContentHandler [as 別名]
def __init__(self, out=None, encoding="iso-8859-1"):
if out is None:
import sys
out = sys.stdout
handler.ContentHandler.__init__(self)
self._out = out
self._ns_contexts = [{}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
self._undeclared_ns_maps = []
self._encoding = encoding
示例5: warning
# 需要導入模塊: import handler [as 別名]
# 或者: from handler import ContentHandler [as 別名]
def warning(self, exception):
self._err_handler.warning(exception)
# ContentHandler methods
示例6: __init__
# 需要導入模塊: import handler [as 別名]
# 或者: from handler import ContentHandler [as 別名]
def __init__(self, out=None, encoding="iso-8859-1"):
handler.ContentHandler.__init__(self)
out = _gettextwriter(out, encoding)
self._write = out.write
self._flush = out.flush
self._ns_contexts = [{}] # contains uri -> prefix dicts
self._current_context = self._ns_contexts[-1]
self._undeclared_ns_maps = []
self._encoding = encoding