docs: def _serialize(
              self,
              element,  # type: ET.Element
              value,  # type: Any
              state  # type: _ProcessorState
      ):
          # type: (...) -> None
          """Serialize the value to the element."""
          xml_value = _hooks_apply_before_serialize(self._hooks, state, value)
  
          # A value is only considered missing, and hence eligible to be replaced by its
          # default only if it is None. Falsey values are not considered missing and are
          # not replaced by the default.
          if xml_value is None:
              if self._default is None:
                  serialized_value = Text('')
              else:
                  serialized_value = Text(self._default)
          else:
              serialized_value = Text(xml_value)
  
          if self._attribute:
              element.set(self._attribute, serialized_value)
          else:
              element.text = serialized_value