ElementTree and DTDs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?ISO-8859-1?Q?J=2E_Pablo_Fern=E1ndez?=

    ElementTree and DTDs

    Hello,

    Is ElementTree supposed to load DTDs? I have some xmls heavy on
    entities and it fails this way:

    Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
    [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.
    >>filename = "revo/xml/a.xml"
    >>import xml.etree.Eleme ntTree as ET
    >>ET.parse(file name)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 862, in
    parse
    tree.parse(sour ce, parser)
    File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 586, in
    parse
    parser.feed(dat a)
    File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 1245, in
    feed
    self._parser.Pa rse(data, 0)
    File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 1201, in
    _default
    self._parser.Er rorColumnNumber )
    xml.parsers.exp at.ExpatError: undefined entity &jcirc;: line 13,
    column 10
    >>import xml.etree.cElem entTree as ET
    >>ET.parse(file name)
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "<string>", line 45, in parse
    File "<string>", line 32, in parse
    SyntaxError: undefined entity &c_j;: line 46, column 17

    Thanks.
  • =?ISO-8859-1?Q?J=2E_Pablo_Fern=E1ndez?=

    #2
    Re: ElementTree and DTDs

    Or is there another library that would handle DTDs correctly,
    performing entity replacements?

    Thanks.

    On May 16, 12:20 am, J. Pablo Fernández <pup...@pupeno. comwrote:
    Hello,
    >
    Is ElementTree supposed to load DTDs? I have some xmls heavy on
    entities and it fails this way:
    >
    Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
    [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
    Type "help", "copyright" , "credits" or "license" for more information.>>f ilename = "revo/xml/a.xml"
    >import xml.etree.Eleme ntTree as ET
    >ET.parse(filen ame)
    >
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 862, in
    parse
        tree.parse(sour ce, parser)
      File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 586, in
    parse
        parser.feed(dat a)
      File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 1245, in
    feed
        self._parser.Pa rse(data, 0)
      File "/usr/lib/python2.5/xml/etree/ElementTree.py" , line 1201, in
    _default
        self._parser.Er rorColumnNumber )
    xml.parsers.exp at.ExpatError: undefined entity &jcirc;: line 13,
    column 10>>import xml.etree.cElem entTree as ET
    >ET.parse(filen ame)
    >
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<string>", line 45, in parse
      File "<string>", line 32, in parse
    SyntaxError: undefined entity &c_j;: line 46, column 17
    >
    Thanks.

    Comment

    • Stefan Behnel

      #3
      Re: ElementTree and DTDs

      J. Pablo Fernández wrote:
      Is ElementTree supposed to load DTDs?
      AFAIR, you have to provide entities by hand.

      Or is there another library that would handle DTDs correctly,
      performing entity replacements?



      Stefan

      Comment

      Working...