[XML-SIG] Need network connection to read local file

Zow Terry Brugger zow at acm.org
Sat Mar 12 07:43:08 CET 2005

Good day,
	I'm a Python XML newbie (experienced with each, just new to Python's
XML support), trying to generate a SAX parser for a local file on my
laptop. Now laptops being what they are, it isn't always connected to the
'net. When I'm not and I try to run my parser, I get the following:

  File "./copyRatings.py", line 78, in ?
  File "/sw/src/root-python23-2.3.3-23/sw/lib/python2.3/xml/sax/expatreader.py", line 107, in parse
  File "/sw/src/root-python23-2.3.3-23/sw/lib/python2.3/xml/sax/xmlreader.py", line 123, in parse
  File "/sw/src/root-python23-2.3.3-23/sw/lib/python2.3/xml/sax/expatreader.py", line 207, in feed
  File "/sw/src/root-python23-2.3.3-23/sw/lib/python2.3/xml/sax/expatreader.py", line 379, in external_entity_ref
  File "/sw/src/root-python23-2.3.3-23/sw/lib/python2.3/xml/sax/saxutils.py", line 277, in prepare_input_source
  File "/sw/lib/python2.3/urllib.py", line 76, in urlopen
    return opener.open(url)
  File "/sw/lib/python2.3/urllib.py", line 181, in open
    return getattr(self, name)(url)
  File "/sw/lib/python2.3/urllib.py", line 297, in open_http
  File "/sw/lib/python2.3/httplib.py", line 712, in endheaders
  File "/sw/lib/python2.3/httplib.py", line 597, in _send_output
  File "/sw/lib/python2.3/httplib.py", line 564, in send
  File "/sw/lib/python2.3/httplib.py", line 532, in connect
IOError: [Errno socket error] (7, 'No address associated with nodename')

(Note that source_file is something like "~/input.xml".)

So it seems that saxutils.prepare_input_source is using urlopen to try to
open whatever resource it's given to parse. That seems fair and useful
much of the time, except when there's no network. So I know this seems
like more of a urllib question, however I imagine that I'm not the first
saxutils user to run into this problem, so I thought I'd start here.

Does anyone have any good fixes or work arounds? Failing that, any
recommendations on where I can get some?

Thanks in advance!
"Zow" Terry Brugger <zow at acm.org>   http://bruggerink.com/~zow
 PGP fingerprint: B4 3D E7 AB CD F1 AA 52  A9 58 53 49 A7 EE 19 5C  17 80 E4 24
"I mean, why do we pay bloody taxes? I know, you know, to buy railings to put
 outside bloody shops so stupid people can't run into the bloody road. But you
 know we're not all stupid. We're not all being nursemaided. I mean why not
 Just have a stupidity tax? JUST TAX THE STUPID PEOPLE!" -AbFab

More information about the XML-SIG mailing list