- def output(cls, out, el, *args, **kw):
- cls(out=out, root=el, *args, **kw).start()
+ def output(cls, out, root, nsnames=None, doctype=None, **kw):
+ if isinstance(doctype, cons.doctype):
+ pass
+ elif doctype is not None:
+ doctype = cons.doctype(root.name, doctype[0], doctype[1])
+ src = itertools.chain(iter([("^", doctype)]), flatiter(root))
+ self = cls(src=src, nsnames=nsnames, **kw)
+ if nsnames is None:
+ self.findnsnames(root)
+ self.first = True
+ for piece in self:
+ out.write(piece)