| 660 | |
| 661 | |
| 662 | class XmlToken: |
| 663 | |
| 664 | def __init__(self, type, name_or_data, attrs = None, line = None, column = None): |
| 665 | assert type in (XML_ELEMENT_START, XML_ELEMENT_END, XML_CHARACTER_DATA, XML_EOF) |
| 666 | self.type = type |
| 667 | self.name_or_data = name_or_data |
| 668 | self.attrs = attrs |
| 669 | self.line = line |
| 670 | self.column = column |
| 671 | |
| 672 | def __str__(self): |
| 673 | if self.type == XML_ELEMENT_START: |
| 674 | return '<' + self.name_or_data + ' ...>' |
| 675 | if self.type == XML_ELEMENT_END: |
| 676 | return '</' + self.name_or_data + '>' |
| 677 | if self.type == XML_CHARACTER_DATA: |
| 678 | return self.name_or_data |
| 679 | if self.type == XML_EOF: |
| 680 | return 'end of file' |
| 681 | assert 0 |
| 682 | |
| 683 | |
| 684 | class XmlTokenizer: |
no outgoing calls
no test coverage detected