17 |
|
|
18 |
import xml.sax |
import xml.sax |
19 |
import xml.sax.handler |
import xml.sax.handler |
20 |
from xml.sax import make_parser, ErrorHandler |
from xml.sax import make_parser, ErrorHandler, SAXNotRecognizedException |
21 |
|
|
22 |
from Thuban import _ |
from Thuban import _ |
23 |
from Thuban.common import * |
from Thuban.common import * |
291 |
parser.setContentHandler(handler) |
parser.setContentHandler(handler) |
292 |
parser.setErrorHandler(ErrorHandler()) |
parser.setErrorHandler(ErrorHandler()) |
293 |
parser.setFeature(xml.sax.handler.feature_namespaces, 1) |
parser.setFeature(xml.sax.handler.feature_namespaces, 1) |
294 |
|
|
295 |
|
# |
296 |
|
# Well, this isn't pretty, but it appears that if you |
297 |
|
# use Python 2.2 without the site-package _xmlplus then |
298 |
|
# the following will fail, and without them it will work. |
299 |
|
# However, if you do have the site-package and you don't |
300 |
|
# call these functions, the reader raises an exception |
301 |
|
# |
302 |
|
# The reason we set these to 0 in the first place is |
303 |
|
# because there is an unresolved issue with external |
304 |
|
# entities causing an exception in the reader |
305 |
|
# |
306 |
|
try: |
307 |
|
parser.setFeature(xml.sax.handler.feature_validation, 0) |
308 |
|
parser.setFeature(xml.sax.handler.feature_external_ges, 0) |
309 |
|
parser.setFeature(xml.sax.handler.feature_external_pes, 0) |
310 |
|
except SAXNotRecognizedException: |
311 |
|
pass |
312 |
|
|
313 |
parser.parse(file) |
parser.parse(file) |
314 |
|
|
315 |
session = handler.theSession |
session = handler.theSession |