Next / Previous / Contents / Shipman's homepage

21. Sox._dictProcessor()

This function implements the interface described in Section 8.1, “content-processor for the dict type. Assuming that all of the keys in the item are xml-names, we add the key-value pairs to attribs. We use Section 22, “Sox._attrEscape(): Escape forbidden characters in attribute values” to substitute standard escape sequences for certain forbidden characters in each attribute value.

sox.py
# - - -   S o x . _ d i c t P r o c e s s o r

    def _dictProcessor(self, item, contentList, attribs):
        '''content-process for dictionaries

          [ type(item) is dict ->
              if all keys in attribs are xml-names ->
                attribs  +:=  key-value pairs from item
              else ->
                attribs  +:=  (anything)
                raise SoxError ]
        '''
        #-- 1
        for key, value in item.items():
            #-- 1 body
            # [ if key is an xml-name ->
            #     attribs[key]  :=  value
            #   else -> raise SoxError ]
            #-- 1.1
            # [ if key is an xml-name ->
            #     I
            #   else -> raise SoxError ]
            self._nameCheck(key)

            #-- 1.2
            attribs[key] = value