[Chicago] python and xml
ianb at colorstudy.com
Mon Jun 5 23:56:59 CEST 2006
Andrew Wilson wrote:
> On 6/5/06, *Ian Bicking* <ianb at colorstudy.com
> <mailto:ianb at colorstudy.com>> wrote:
> The xml.* modules are kind of crap, IMHO. ElementTree doesn't do
> validation. Those two plus the ones I mention above seem to be the top
> tier/most viable libraries.
> Um....Kid uses ElementTree, and Kid requires that its templates be
> validating XML. I've debugged errors in my XML errors when
> Kid/ElementTree kicked out validation errors. So, while I'm not
> terribly familiar with ElementTree, it must have SOME kind of
> validation.... If not, how does Kid work / what is Kid doing?
It validates that it is syntactically valid XML, but it doesn't check
the DTD. As an example, this is syntactically valid XML:
But the (X)HTML DTD I believe disallows that, and this is valid (X)HTML:
It actually would be somewhat inappropriate for Kid to check validity.
It would make more sense to check the output from Kid for validity.
You'll encounter a kind of weird artifact of DTD's if you use in
your Kid template, I think (though they may have fixed that).
means something in HTML (and XHTML?), but XML markup is only HTML if you
add and parse the (X)HTML DTD, and learn about the entities that are
valid in that document. Without the DTD the only valid entities you can
use are numerical unicode characters like ' '.
This is where XML starts getting hard, I guess. I never bother with
validation myself, but then I only use XML in passing.
More information about the Chicago