Next / Previous / Contents / Shipman's homepage

37. class Elt: One open element

Each instance of this class represents one element whose start tag has been written but whose end tag is pending. The Sox class maintains a stack of these instances in order to insure start-end tag matching. The intended functions below are formalized versions of the interface defined in Section 4.3, “The Elt class: An element in progress”.
# - - - - -   c l a s s   E l t

class Elt(object):
    '''Represents a partially built XML element.

        Elt(sox, tag):
          [ (sox is the containing Sox instance) and
            (tag is an xml-name) ->
              return a new Elt instance with those values ]
        .sox:      [ as passed to constructor ]
        .tag:      [ as passed to constructor ]
          [ if self is the top of sox's stack ->
              sox  :=  sox with its stack popped
            else -> raise SoxError ]
        .__enter__(): [ I ]
        .__exit__(): [ same as .end() ]