def __call__(self, stream):
    doctype_inserted = False
    for (kind, data, pos) in stream:
        if (not doctype_inserted):
            doctype_inserted = True
            if (kind is XML_DECL):
                (yield (kind, data, pos))
                (yield self.doctype_event)
                continue
            (yield self.doctype_event)
        (yield (kind, data, pos))
    if (not doctype_inserted):
        (yield self.doctype_event)
def __call__(self, stream):
    doctype_inserted = False
    for (kind, data, pos) in stream:
        if (not doctype_inserted):
            doctype_inserted = True
            if (kind is XML_DECL):
                (yield (kind, data, pos))
                (yield self.doctype_event)
                continue
            (yield self.doctype_event)
        (yield (kind, data, pos))
    if (not doctype_inserted):
        (yield self.doctype_event)