<s> '''<STR_LIT>''' <EOL> __docformat__ = '<STR_LIT>' <EOL> __version__ = '<STR_LIT>' <EOL> from layout . content import * <EOL> class ContentBuilder ( object ) : <EOL> element_class = ContentElement <EOL> def __init__ ( self , document ) : <EOL> self . document = document <EOL> self . parent_stack = [ None ] <EOL> self . sibling_stack = [ None ] <EOL> def feed ( self , data ) : <EOL> raise NotImplementedError ( '<STR_LIT>' ) <EOL> def begin_element ( self , name , attributes ) : <EOL> parent = self . parent_stack [ - <NUM_LIT:1> ] <EOL> previous_sibling = self . sibling_stack . pop ( ) <EOL> element = self . element_class ( <EOL> self . document , name , attributes , parent , previous_sibling ) <EOL> if parent : <EOL> parent . add_child ( element ) <EOL> self . document . element_modified ( parent ) <EOL> else : <EOL> self . document . set_root ( element ) <EOL> self . parent_stack . append ( element ) <EOL> self . sibling_stack . append ( element ) <EOL> self . sibling_stack . append ( None ) <EOL> if element . id : <EOL> self . document . element_ids [ element . id ] = element <EOL> def end_element ( self , name ) : <EOL> self . parent_stack . pop ( ) <EOL> self . sibling_stack . pop ( ) <EOL> def text ( self , text ) : <EOL> if self . document . root : <EOL> self . parent_stack [ - <NUM_LIT:1> ] . add_text ( text ) <EOL> self . document . element_modified ( self . parent_stack [ - <NUM_LIT:1> ] ) </s>
