I decided to use SAX to parse my xml file.
But the parser crashes on:
File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError
raise exception
xml.sax._except ions.SAXParseEx ception: NCBI_Entrezgene .dtd:8:0: error in processing external entity reference
This is caused by:
<!DOCTYPE Entrezgene-Set PUBLIC "-//NCBI//NCBI Entrezgene/EN"
"NCBI_Entrezgen e.dtd">
If I remove it, it parses normally.
I've created my parser like this:
import sys
from xml.sax import make_parser
from handler import EntrezGeneHandl er
fopen = open("mouse2.xm l", "r")
ch = EntrezGeneHandl er()
saxparser = make_parser()
saxparser.setCo ntentHandler(ch )
saxparser.parse (fopen)
And the handler is:
from xml.sax import ContentHandler
class EntrezGeneHandl er(ContentHandl er):
"""
A handler to deal with EntrezGene in XML
"""
def startElement(se lf, name, attrs):
print "Start element:", name
So it doesn't do much yet. And still it crashes...
How can I tell the parser not to look at the DOCTYPE declaration.
On a website:
it states that the SAX parsers are not validating, so this error shouldn't
even occur?
Cheers,
Willem
But the parser crashes on:
File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError
raise exception
xml.sax._except ions.SAXParseEx ception: NCBI_Entrezgene .dtd:8:0: error in processing external entity reference
This is caused by:
<!DOCTYPE Entrezgene-Set PUBLIC "-//NCBI//NCBI Entrezgene/EN"
"NCBI_Entrezgen e.dtd">
If I remove it, it parses normally.
I've created my parser like this:
import sys
from xml.sax import make_parser
from handler import EntrezGeneHandl er
fopen = open("mouse2.xm l", "r")
ch = EntrezGeneHandl er()
saxparser = make_parser()
saxparser.setCo ntentHandler(ch )
saxparser.parse (fopen)
And the handler is:
from xml.sax import ContentHandler
class EntrezGeneHandl er(ContentHandl er):
"""
A handler to deal with EntrezGene in XML
"""
def startElement(se lf, name, attrs):
print "Start element:", name
So it doesn't do much yet. And still it crashes...
How can I tell the parser not to look at the DOCTYPE declaration.
On a website:
it states that the SAX parsers are not validating, so this error shouldn't
even occur?
Cheers,
Willem
Comment