[XML-SIG] Locator and unknown line and column numbers

Walter Dörwald walter.doerwald at livinglogic.de
Wed Mar 17 08:03:51 EST 2004


Hello XML-SIG!

How should a parser report unknown line and column numbers?

I have a SAX parser for sgmlop that handles line numbers
simply by splitting the input into lines and feeding
them to the parser. This takes care of the line numbers, but
feeding character by character to the parser to get column
numbers would probably be to slow, so the column number is
unknown.

I've implemented getColumnNumber() as:
    def getColumnNumber(self):
       return None

as None is IMHO the best representation of "unknown".
Unfortunately this doesn't work with SAXParseException,
because SAXParseException.__str__() uses "%d" for
formatting the column number.

So should I use some nonsense integer value for this
or should SAXParseException.__str__() be changed to
be able to handle None?

Bye,
    Walter Dörwald





More information about the XML-SIG mailing list