def _render(self,nsmap):
        """Generator rendering this model as an XML fragment."""
        #  Determine opening and closing tags
        pushed_ns = False
        if self.meta.namespace:
            namespace = self.meta.namespace
            prefix = self.meta.namespace_prefix
            try:
                cur_ns = nsmap[prefix]
            except KeyError:
                cur_ns = []
                nsmap[prefix] = cur_ns
            if prefix:
                tagname = "%s:%s" % (prefix,self.meta.tagname)
                open_tag_contents = [tagname]
                if not cur_ns or cur_ns[0] != namespace:
                    cur_ns.insert(0,namespace)
                    pushed_ns = True
                    open_tag_contents.append('xmlns:%s="%s"'%(prefix,namespace))
                close_tag_contents = tagname
            else:
                open_tag_contents = [self.meta.tagname]
                if not cur_ns or cur_ns[0] != namespace:
                    cur_ns.insert(0,namespace)
                    pushed_ns = True
                    open_tag_contents.append('xmlns="%s"'%(namespace,))
                close_tag_contents = self.meta.tagname
        else:
            open_tag_contents = [self.meta.tagname] 
            close_tag_contents = self.meta.tagname
        used_fields = set()
        open_tag_contents.extend(self._render_attributes(used_fields,nsmap))
        #  Render each child node
        children = self._render_children(used_fields,nsmap)
        try:
            first_child = children.next()
        except StopIteration:
            yield "<%s />" % (" ".join(open_tag_contents),)
        else:
            yield "<%s>" % (" ".join(open_tag_contents),)
            yield first_child
            for child in children:
                yield child
            yield "</%s>" % (close_tag_contents,)
        #  Check that all required fields actually rendered something
        for f in self._fields:
            if f.required or f not in used_fields:
                raise RenderError("Field '%s' is missing" % (f.field_name,))
        #  Clean up
        if pushed_ns:
            nsmap[prefix].pop(0)
dataset/ETHPy150Open rfk/dexml/dexml/__init__.py/Model._render/operator `and` -> `or`