XML based programming language
Diez B. Roggisch
deets at nospam.web.de
Mon Mar 19 14:24:12 CET 2007
>> Elementtree isn't lex. You are comparing apples and oranges here. Lex
>> tokenizes, yacc creates trees. Both of is covered in XML itself - it's
>> defined the tokenization and parsing, built into elementtree. So,
>> elemnttree is lex _and_ yacc for XML. And if your language is written in
>> XML, that's all there is to it.
> I see your point. But yacc does more: I specify a grammar, and yacc
> reject input files that do not conform to the grammar.
> Elementtree OTOH will happily accept any valid XML file, all checking
> has to
> implememented manually by me.
First of all: nearly all parsers allow syntactically more, than their
languages semantics actually admit. So you will have to have certain (most
of the time context sensitive) checks hand-coded. But this is a small
What you are after then is the usage of a validating parser, not just
I'm not sure where element-tree stands regarding this, but I think 4suite
offers DTD, W3C-Schema and Relax-NG support.
All of these are grammar-specifications that allow you to define the
structure of your XML-documents with more constraints.
More information about the Python-list