XML

Paul Boddie paul at boddie.net
Tue Jun 24 05:21:20 EDT 2003


Roman Suzi <rnd at onego.ru> wrote in message news:<mailman.1056387220.30017.python-list at python.org>...
> 
> OK. When I was talking about plain text, I had in mind that it 
> has some proprietary format. For example, I can easily write:
> 
> ------------------
> foo = "123"
> bar = "456"
> zoo = "la\"lala"
> ------------------
> 
> And it's not very hard to parse that. 

Well, you can just write that in a module and have Python import it.
;-) And I don't see anything wrong with that, actually. In various
situations, particularly the oft-quoted configuration file example,
this is a lot more interesting than XML, for Python applications at
least.

> In case of XML I will need something like
> 
> <?xml version="1.0"?>
> <foo>123</foo><bar>456</bar><zoo>la"lala</zoo>
> 
> - not a big deal, but it's harder to parse. And also XML software keeps
> changing (or so it seems), and this gives a sense of instability.

How hard is it to call a parse function on some XML module? (Bearing
in mind that your example isn't a well-formed XML document since it
doesn't have a single root element, even though I do like using "zoo"
elements in examples myself. :-) )

> XML always gives me a feeling that I do not fully master it (especially it's
> DTD part)! And this is after two years of trying to understand it. (Cf: with
> Python felt at home after a week or two!)

It can often be a question of ambition, since I can imagine that many
people don't really use DTDs or XML Schemas to get their work done. In
any case, it isn't clear what the corresponding technology to DTD is
in the Python environment - optional, but not yet invented, static
type annotations?

> P.S. Just look at the neighboor thread:
> Subject: minidom toxml() not emitting attribute namespace qualifier
> 
> > Using Python 2.2.3, with this example code:
> 
> [Code elided]
> 
> > The output is missing the "myns" namespace qualifier on the "att"
> > attribute. Can someone tell me what I'm doing wrong?

Could be that if one is calling setAttributeNS on an element, one has
to specify the prefix as part of the name parameter - that isn't
obvious and I made that mistake before I became more acquainted with
the API.

> That's a bug in minidom.
> 
> I reported it back in November 2002, but I wasn't precise enough about version
> numbers, so it went unaddressed.

Well, I was convinced about the bug status until I looked deeper and
realised that I was doing stuff wrong. Perhaps it's a documentation
issue, and perhaps the maintainers of PyXML really have a lot of work
to do, and perhaps it isn't easy to maintain various standard API
implementations (as Andrew Kuchling suggests), but I do believe that
the various XML technologies available for Python are very useful
things to be familiar with, despite what people may claim.

It may be the case that you don't see a need for XML in your work. In
my opinion it's completely acceptable to not use XML if you find it
completely irrelevant, unfathomable or opaque, but I respect your
desire to become aware of what the technology can offer. I'm reminded
of the occasional article written by people who ask others to
"convince me why I should run Linux" - the only useful response is
that if one can't see a need to try it without writing a public
document asking others to persuade them, then they probably shouldn't
be spending too much time worrying about it.

Paul




More information about the Python-list mailing list