refactoring xhtml serializer

@fosdev please don't merge, for discussion only