#34 SAXParseException does not implement Locator

open-postponed
nobody
None
5
2003-10-22
2003-07-28
No

SAXParseException does not implement Locator, which means that
when I want to do the following

try {
parser.parse(inpsrc);
} catch (SAXParseException e) {
// do something useful with info, and record location it occurred in
}

I have the problem in the catch block that I can't create a new
SAXParseException and keep the Locator info easily, because
although the exception wants a Locator as the second constructor
arg, the SAXParseException is not a Locator. Also, if I want to keep
the information around somewhere else I can't use the copy
constructor of LocatorImpl, because, again, SAXParseException is not
a Locator.

The only solution is to do

Locator loc = new LocatorImpl();
loc.setPublicId(e.getPublicId());
loc.setSystemId(e.getSystemId());
// and so on...

which is not exactly pleasant.

Discussion

  • Anonymous - 2003-10-22

    Logged In: YES
    user_id=44117

    Yes, this has always annoyed me. It may get
    fixed in the next revision, despite the backward
    compatibility problem itl'll cause.

     
  • Anonymous - 2003-10-22
    • labels: 340834 -->
    • milestone: 129196 -->
    • status: open --> open-postponed
     

Log in to post a comment.