9.14. Bringing It All Together

We end this chapter with a complete copy of the finished xgrep.

 CD-ROM reference=9043.txt import string,os,sys import re from pyxie import * # Use "bits" to store boolean options MARK_HITS = 1 USE_EVENT_STYLE = 1 << 1 USE_TREE_STYLE = 1 << 2 VALIDATE = 1 << 3 MATCH_ATTRIBUTE_NAME = 1 << 4 MATCH_ATTRIBUTE_VALUE = 1 << 5 MATCH_PROCESSING_INSTRUCTION = 1 << 6 MATCH_ELEMENT_TYPE_NAME = 1 << 7 MATCH_CHARACTER_DATA = 1 << 8 PARENT_CONTEXT = 1 << 9 ANCESTOR_CONTEXT = 1 << 10 CHILD_CONTEXT = 1 << 11 DESCENDANT_CONTEXT = 1 << 12 SIBLING_CONTEXT = 1 << 13 # PrintMatch subroutine called from many places in the code # prints the match details. def PrintMatch(filename,description,line,mo,StartOfHit, EndOfHit,out): out.write ...

Get XML Processing with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.