From: Matt Gushee Date: 2002-10-01T04:47:26+09:00 Subject: Re: REXML namespace support On Tue, Oct 01, 2002 at 04:28:43AM +0900, Bob Hutchison wrote: > > > > You mean 'prefix-to-namespace mappings are defined ...', don't you? Sorry > > to be picky, but XML namespaces are confusing enough without imprecise > > explanations. > > I guess I meant both. > > I should also have said 'namespace2' in element2 in my example. > > You are right, it is confusing enough (and it doesn't matter how precise you > are, it is still confusing) True. I used to teach an intro-to-XML course. The students were by no means dumb people, but somehow the Namespaces section always managed to go overtime. > >> > >> > >> > >> > >> is legal (though a questionable practice, and ignoring opinions w.r.t. > >> Namespaces being URLs). In this example there are two namespaces but only > >> one prefix is used. In general, the prefix mapping to namespace is scoped. > >> This makes it impossible to answer the question you want to ask unless you > >> can identify a spot in the document. > > > > I would say 'unreliable' rather than 'impossible'. You're quite right > > that it's legal to reuse prefixes, but it would be very counterintuitive > > to do so, and I doubt that it's likely to happen in practice; I've > > certainly never seen it (except in examples contrived to show that it > > can be done). Have you? > > Yes, actually, I have. I certainly don't recommend the practice, but I've > seen it. If you are writing tools for XML you have to be prepared for it. Wow. Okay. Just out of curiousity, are you talking about documents written by human authors, or generated XML, or both? It's hard to understand why anyone would deliberately do that. Though, now that I think about it, it would be pretty easy to get reused prefixes in a composite document, if you didn't specifically provide a means to uniquify the prefixes when assembling the components. > > Which means that, if a certain degree of doubt is acceptable (e.g. doing > > a first-pass analysis of a large collection of XML documents, with > > thorough testing to take place later), there shouldn't be a problem with > > just pulling out the first available mapping (though I don't think I'd > > choose that approach myself unless I were under extreme time pressure). > > I wouldn't recommend it. Nor would I. I guess I'm just resigned to living in a world full of kludges. -- Matt Gushee Englewood, Colorado, USA mgushee@havenrock.com http://www.havenrock.com/