Package advene :: Package model :: Package parsers :: Module base_xml :: Class XmlParserBase
[hide private]
[frames] | no frames]

Class XmlParserBase

source code

object --+
         |
        XmlParserBase
Known Subclasses:

TODO write a better documentation

The idea is that subclasses define ``handle_X`` methods where X is the unqualified tag.

Property `package` holds the package to parse into.

DEPRECATED: Property `backend` and `package_id` are useful to feed the package's backend.

Property `current` always points to the current element (with the ElementTree API). Note that the element will have its attribute, but not its text nor its sub-elements. To wait for an element to be completely constructed, invoke method `complete_current`. However, to parse subelements, you may prefer to use methods `required`, `optional` and `sequence`, that will check the structure of subelements, then invoke the corresponding `handle_X` methods. Note that `required` and `optional` will return the value returned by `handle_X` (`optional` returns None if the element is not found).

Method `get_attribute` is a shortcut for ``current.get(k[, d])`` but will raise a `ParseError` with the appopriate message if the attribute is missing and no default value is provided.

Property `ns_stack` is a list of (prefix, uri) pairs used as a stack for namespaces.

For advanced use, property `stream` holds the underlying `Stream` instance.

See `advene.model.parsers.advene_xml` for an example.

Instance Methods [hide private]
 
__init__(self, file_, package, namespace_uri, root)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
get_attribute(self, key, default=_RAISE) source code
 
parse(self) source code
 
required(self, tag, *args, **kw) source code
 
optional(self, tag, *args, **kw) source code
 
sequence(self, tag, *args, **kw)
NB: this methods allows an *empty* sequence.
source code
 
complete_current(self) source code
 
_handle(self, args, kw) source code
 
_check_end(self, elem) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]
  current
  ns_stack

Inherited from object: __class__

Method Details [hide private]

__init__(self, file_, package, namespace_uri, root)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

sequence(self, tag, *args, **kw)

source code 

NB: this methods allows an *empty* sequence.

If you want a sequence with at least 1 element, use the following pattern::

   required(mytag)
   sequence(mytag)

Property Details [hide private]

current

Get Method:
unreachable.current(self)

ns_stack

Get Method:
unreachable.ns_stack(self)