def Tag(self, tag): |
assert id(tag) not in self.visited |
try: |
tag.parent = self.parents[-1] |
except IndexError: |
tag.parent = None |
self.visited[id(tag)] = 1 |
tagname = getattr(tag, 'xmlname', tag.__class__.__name__) |
if self.curindent and not self._isinline(tagname): |
self.write("\n" + u' ' * self.curindent) |
if tag: |
self.curindent += self.indent |
-> self.write(u'<%s%s>' % (tagname, self.attributes(tag))) |
self.parents.append(tag) |
map(self.visit, tag) |
self.parents.pop() |
self.write(u'</%s>' % tagname) |
self.curindent -= self.indent |
else: |
nameattr = tagname+self.attributes(tag) |
if self._issingleton(tagname): |
self.write(u'<%s/>' % (nameattr,)) |
else: |
self.write(u'<%s></%s>' % (nameattr, tagname)) |