[XML-SIG] Accessing internal entities with minidom or 4DOM

Phil Glaser StillSmallVoice@DirectvInternet.com
Sun, 21 Jul 2002 19:53:52 -0400


Hi,

I am attempting to parse a an XML document and want to manipulate the
internal ENTITies. I've tried with both minidom and 4DOM and am not having
much luck. My doctype declaration looks like this:

<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "docbookx.dtd"
[
<!ENTITY tool_dbdtd "Docbook DTD">
<!ENTITY tool_dbxsl "Docbook XSL">
<!ENTITY tool_edit "Emacs">
<!ENTITY tool_valid "nsgmls">
<!ENTITY tool_xsler "xsltproc">
<!ENTITY tool_fober "FOP">
]>

With minidom I tried tried the following:
>>> from xml.dom import minidom
>>> minidoc =
minidom.parse("d:\data\publications\web\UsingDocbook\usingdb.xml")
>>> entities = minidoc.doctype.internalSubset
>>> entities
>>> print entities
None

If I read the documentation correctly, entities should have ended up as a
list giving the internal subset. But it ends up None.

With 4DOM I tried as follows:

>>> from xml.dom.ext.reader import Sax2
>>> reader = Sax2.Reader()
>>> doc =
reader.fromStream("d:\data\publications\web\usingdocbook\usingdb.xml")
>>> doc.childNodes
<NodeList at 844f48: [<DocumentType Node at 908c30: Name='book' with 0
entities and 0 notations>, <Element Node at 920010: Name='book' with 0
attributes and 7 children>]>

The only documentation I could find for 4DOM
(http://pyxml.sourceforge.net/topics/howto/section-DOM.html) did not give
any details about how to access the internal subset, but doc.childNodes
would appear to indicate that it's not seeing any entities. (If there's more
documentation anywhere please let me know.)

Any guidance would be greatly appreciated.

Thanks!


Philip Glaser
Principal and Software Architect
Sustainable Software Solutions, LLC
StillSmallVoice@DirectvInternet.com
www.sustainsoft.com
973-951-9522