3 ms·
How would this work, exactly? Usually stream parsing requires handler functions, which would imply passing functions at the commandline. I can't think of how yo
by djacobs 16y ago
How would this work, exactly? Usually stream parsing requires handler functions, which would imply passing functions at the commandline. I can't think of how you would do this with pipes.
- iwr 16y agoYou could write a wrapper that outputs SAX events to predetermined files or named pipes, say, selectable as command line arguments; for instance, the startElement event could be outputted to startElement.txt. Then your script can monitor these files and do the processing from there. I'm sure there are better ways to do it, though.
- djacobs 16y agoYou're definitely right, that will work. I guess my point is: the OP seems to be wanting a dynamic way to handle XML at the commandline such that he can handle new types of events on the fly by piping together a parser with other Unix filters, etc. Doing things the SAX way implies creating hard and fast (and specific) handlers for each type of event, indicating that you're anticipating these events in advance. I'm sure some handlers could be generalized a bit (for example, scanning for regular expressions). But I don't think that the SAX/commandline solution is much better than the SAX/program solution. Am I missing something?