[lxml-dev] iterparse and namespaces
Ross Vandegrift
ross at kallisti.us
Tue Mar 17 20:47:13 CET 2009
On Tue, Mar 17, 2009 at 03:48:54PM +0100, Stefan Behnel wrote:
> jholg at gmx.de wrote:
> > Is there a usecase for "give me every element x from whatever namespace"?
>
> Yep, I guess that's why it doesn't work. :)
While I realize this is a a different problem than the original poster
had...
Suppose you have to interoperate with an XML generator that changes
the namespace based on an unrelated version number of the supporting
platform and you had no way of knowing what namespaces a document
would use? Further, you do know that the sematic content of the tags
is unchanged.
That situation led me to want an XML toolkit that would let me throw
away namespace data - because stupid people have done stupid things
with XML namespaces. And I have to live with it, whether it's right
or not.
I ended up solving the problem by search-and-replacing an XSLT sheet
with heuristically gleaned version information and using that XSLT to
create data structures I could actually do something with.
Poetic justice, I'd say, that XML's structured approach can lead to
a problem solvable only by ad-hoc parsering of a serialized XML doc :)
(Though in retrospect, I think I could use lxml's nsmap members to
glean the namespace information build unversioned data structures
without the really ugly intermediate transform)
--
Ross Vandegrift
ross at kallisti.us
"If the fight gets hot, the songs get hotter. If the going gets tough,
the songs get tougher."
--Woody Guthrie
More information about the lxml-dev
mailing list