[XML-SIG] ignoring "Undeclared entity" errors?

Steven Knight knight at baldmt.com
Sun Dec 5 21:34:19 CET 2004

Here's the problem I'm trying to solve:

I want to assemble fragments of XML documentation that I intend to
scatter throughout my Python modules.  The fragments will use custom tags
describing the content they're documenting.  I'm planning to preprocess
these custom tags into the right format for the output I'm generating
(DocBook, nroff, etc.).

I would like the text fragments to be able to contain entities that can
be passed through or preprocessed.  These entities *will* be declared
when I process the fully-assumbled documentation, but are not declared
for each individual fragment.  When I try to process an individual
fragment without the declarations, I of course get "Undeclared entity"
fatal errors for these entities, which terminates parsing of the fragment.

Defining an ErrorHandler.fatalError() method lets me detect the
"Undeclared entity" error, but doesn't change the fact that the parsing

Having to declare a DTD just to be able to perform some specific
preprocessing on an otherwise well-formed fragment of XML feels way
too heavyweight to me.  I'm almost at the point of filtering all of
the &entity; uses in my text so they don't look like entities and then
restoring them, just to not have to jump through the parser's hoops,
but that feels like cheating.

Am I just going about this the wrong way?  Is there some easier way
io just be able to preprocess some XML-formatted data without having
to worry about a declaring a DTD?  Or to tell the parser that I'm not
concerned about the entities in my fragment?


More information about the XML-SIG mailing list