Re: XML and namespaces

2005-12-19 Thread and-google
Uche Ogbuji <[EMAIL PROTECTED]> wrote: > Andrew Clover also suggested an overly-legalistic argument that current > minidom behavior is not a bug. I stick by my language-law interpretation of spec. DOM 2 Core specifically disclaims any responsibility for namespace fixup and advises the application

Re: XML and namespaces

2005-12-12 Thread Alan Kennedy
[Paul Boddie] > It's > interesting that minidom plus PrettyPrint seems to generate the xmlns > attributes in the serialisation, though; should that be reported as a > bug? I believe that it is a bug. [Paul Boddie] > Well, with the automagic, all DOM users get the once in a lifetime > chance to ex

Re: XML and namespaces

2005-12-11 Thread Paul Boddie
Alan Kennedy wrote: > Serialisation and namespace normalisation are both in the realm of DOM > Level 3, whereas minidom is only L2 compliant. Automagically introducing > L3 semantics into the L2 implementation is the wrong thing to do. I think I'll have to either add some configuration support, in

Re: XML and namespaces

2005-12-11 Thread Alan Kennedy
[Paul Boddie] > However, > wouldn't the correct serialisation of the document be as follows? > > > Yes, the correct way to override a default namespace is an xmlns="" attribute. [Paul Boddie] > As for the first issue - the presence of the xmlns attribute in the > serialised document - I

Re: XML and namespaces

2005-12-11 Thread Paul Boddie
Alan Kennedy wrote: [Discussing the appearance of xmlns="DAV:"] > But that's incorrect. You have now defaulted the namespace to "DAV:" for > every unprefixed element that is a descendant of the href element. [Code creating the no_ns element with namespaceURI set to None] > > I must admit tha

Re: XML and namespaces

2005-12-07 Thread Paul Boddie
Alan Kennedy wrote: > Well, if your purpose is to make a point about minidom and DOM standards > compliance in relation to serialisation of namespaces, then what you're > doing wrong is to use a library that bears no relationship to the DOM to > make your point. Alright. I respectfully withdraw li

Re: XML and namespaces

2005-12-07 Thread Paul Boddie
Paul Boddie wrote: > It is difficult to say whether this usage of the API is correct or not, > judging from the > Web site's material [...] Some more on this: I found an example on the libxml2 mailing list (searching for "xmlNewNs default namespace") which is similar to the one I gave: http://m

Re: XML and namespaces

2005-12-07 Thread Alan Kennedy
[Alan Kennedy] >>Don't confuse libxml2dom with libxml2. [Paul Boddie] > Well, quite, but perhaps you can explain what I'm doing wrong with this > low-level version of the previously specified code: Well, if your purpose is to make a point about minidom and DOM standards compliance in relation to

Re: XML and namespaces

2005-12-07 Thread Alan Kennedy
[Fredrik Lundh] > It's libxml2 that does all the work, and the libxml2 > authors claim that libxml2 implements the DOM level 2 document model, > but with a different API. That statement is meaningless. The DOM is *only* an API, i.e. an interface. The opening statement on the W3C DOM page is """

Re: XML and namespaces

2005-12-07 Thread Fredrik Lundh
Alan Kennedy wrote: > [Fredrik Lundh] > > but isn't libxml2dom just a binding for libxml2? as I mention above, I had > > libxml2 > > in mind when I wrote "widely used", not the libxml2dom binding itself. > > No, libxml2dom is Paul Boddie's DOM API compatibility layer on top of > the cpython bind

Re: XML and namespaces

2005-12-06 Thread Paul Boddie
Alan Kennedy wrote: > Don't confuse libxml2dom with libxml2. Well, quite, but perhaps you can explain what I'm doing wrong with this low-level version of the previously specified code: import libxml2mod document = libxml2mod.xmlNewDoc(None) element = libxml2mod.xmlNewChild(document, None, "href",

Re: XML and namespaces

2005-12-06 Thread Paul Boddie
Alan Kennedy wrote: > Libxml2dom is of alpha quality, according to its CheeseShop page anyway. Given that I gave it that classification, let me explain that its alpha status is primarily justified by the fact that it doesn't attempt to cover the entire DOM API. As I mentioned in my original contri

Re: XML and namespaces

2005-12-06 Thread Alan Kennedy
[Fredrik Lundh] > but isn't libxml2dom just a binding for libxml2? as I mention above, I had > libxml2 > in mind when I wrote "widely used", not the libxml2dom binding itself. No, libxml2dom is Paul Boddie's DOM API compatibility layer on top of the cpython bindings for libxml2. From the Cheese

Re: XML and namespaces

2005-12-06 Thread Fredrik Lundh
Alan Kennedy wrote: > [Fredrik Lundh] > > my point was that (unless I'm missing something here), there are at > > least two widely used implementations (libxml2 and the 4DOM domlette > > stuff) that don't interpret the spec in this way. > > Libxml2dom is of alpha quality, according to its CheeseSh

Re: XML and namespaces

2005-12-06 Thread Alan Kennedy
[EMAIL PROTECTED] > You're the one who doesn't seem to clearly understand XML namespaces. > It's your position that is bewildering, not XML namespaces (well, they > are confusing, but I have a good handle on all the nuances by now). So you keep claiming, but I have yet to see the evidence. > Agai

Re: XML and namespaces

2005-12-06 Thread Alan Kennedy
[Fredrik Lundh] > my point was that (unless I'm missing something here), there are at > least two widely used implementations (libxml2 and the 4DOM domlette > stuff) that don't interpret the spec in this way. Libxml2dom is of alpha quality, according to its CheeseShop page anyway. http://chees

Re: XML and namespaces

2005-12-05 Thread uche . ogbuji
Wilfredo Sánchez Vega: """ I'm having some issues around namespace handling with XML: >>> document = xml.dom.minidom.Document() >>> element = document.createElementNS("DAV:", "href") >>> document.appendChild(element) >>> document.toxml() '\n'

Re: XML and namespaces

2005-12-05 Thread uche . ogbuji
Alan Kennedy """ Although I am sympathetic to your bewilderment: xml namespaces can be overly complex when it comes to the nitty, gritty details. """ You're the one who doesn't seem to clearly understand XML namespaces. It's your position that is bewildering, not XML namespaces (well, they are con

Re: XML and namespaces

2005-12-05 Thread Fredrik Lundh
Alan Kennedy wrote: > [Fredrik Lundh] > > and this hypothetical situation is different from the current situation in > > exactly what way? > > Hmm, not sure I understand what you're getting at. > > If changes are made to minidom that implement non-standard behaviour, > there are two groups of peop

Re: XML and namespaces

2005-12-05 Thread Alan Kennedy
[Alan Kennedy] >>On the contrary, once you start second guessing the standards and making >>guesses about what users are really trying to do, and making decisions >>for them, then some people are going to get different behaviour from >>what they rightfully expect according to the standard. People w

Re: XML and namespaces

2005-12-05 Thread Fredrik Lundh
> Leaving such attributes out by default, whilst claiming some kind of > "fine print" standards compliance, is really a recipe for unnecessary user > frustration. > On the contrary, once you start second guessing the standards and making > guesses about what users are really trying to do, and maki

Re: XML and namespaces

2005-12-05 Thread Alan Kennedy
[Fredrik Lundh] >>can anyone perhaps dig up a DOM L2 implementation that's not written >>by anyone involved in this thread, and see what it does ? [Paul Boddie] > document = libxml2dom.createDocument(None, "doc", None) > top = document.xpath("*")[0] > element = document.createElementNS("DAV:",

Re: XML and namespaces

2005-12-05 Thread Paul Boddie
Fredrik Lundh wrote: > can anyone perhaps dig up a DOM L2 implementation that's not written > by anyone involved in this thread, and see what it does ? Alright. Look away from the wrapper code (which I wrote, and which doesn't do anything particularly clever) and look at the underlying libxml2 ser

Re: XML and namespaces

2005-12-05 Thread Fredrik Lundh
> Is this automatic creation an expected behaviour? > Of course. > Not exactly a bug /.../ So it should probably be optional. > My interpretation of namespace nodes is that the application is > responsible /.../ > I'm sorry but you're wrong on this. > Well, my reading of the DOM L2 spec is suc

Re: XML and namespaces

2005-12-05 Thread Alan Kennedy
[EMAIL PROTECTED] > The current, erroneous behavior, which you advocate, is of the same > bug. Minidom is an XML Namespaces aware API. In XML Namespaces, the > namespace URI is *part of* the name. No question about it. In Clark > notation the element name that is specified in > > element

Re: XML and namespaces

2005-12-05 Thread uche . ogbuji
I wrote: """ The reality is that once the poor user has done: element = document.createElementNS("DAV:", "href") They are following DOM specification that they have created an element in a namespace, and you seem to be arguing that they cannot usefully have completed their work until they also do

Re: XML and namespaces

2005-12-05 Thread uche . ogbuji
Alan Kennedy: """ These namespace declaration nodes, i.e. attribute nodes in the xml.dom.XMLNS_NAMESPACE namespace, are a pre-requisite for any namespaced DOM document to be well-formed, and thus naively serializable. The argument could be made that application authors should be protected from the

Re: XML and namespaces

2005-12-03 Thread Alan Kennedy
[EMAIL PROTECTED] >>Oh no. That only means that namespace declaration attributes are not >>created in the DOM data structure. However, output has to fix up >>namespaces in .namespaceURI properties as well as directly asserted >>"xmlns" attributes. It would be silly for DOM to produce malformed >

Re: XML and namespaces

2005-12-03 Thread and-google
Uche <[EMAIL PROTECTED]> wrote: > Of course. Minidom implements level 2 (thus the "NS" at the end of the > method name), which means that its APIs should all be namespace aware. > The bug is that writexml() and thus toxml() are not so. Not exactly a bug - DOM Level 2 Core 1.1.8p2 explicitly leav

Re: XML and namespaces

2005-12-02 Thread uche . ogbuji
Alan Kennedy: """ > Oh no. That only means that namespace declaration attributes are not > created in the DOM data structure. However, output has to fix up > namespaces in .namespaceURI properties as well as directly asserted > "xmlns" attributes. It would be silly for DOM to produce malformed >

Re: XML and namespaces

2005-12-02 Thread Alan Kennedy
[AMK] > """ > (I assume not. Section 1.3.3 of the DOM Level 3 says "Similarly, > creating a node with a namespace prefix and namespace URI, or changing > the namespace prefix of a node, does not result in any addition, > removal, or modification of any special attributes for declaring the > approp

Re: XML and namespaces

2005-12-02 Thread A.M. Kuchling
On 2 Dec 2005 06:16:29 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Of course. Minidom implements level 2 (thus the "NS" at the end of the > method name), which means that its APIs should all be namespace aware. > The bug is that writexml() and thus toxml() are not so. Hm, OK.

Re: XML and namespaces

2005-12-02 Thread uche . ogbuji
Quoting Andrew Kuchling: """ > >>> element = document.createElementNS("DAV:", "href") This call is incorrect; the signature is createElementNS(namespaceURI, qualifiedName). """ Not at all, Andrew. "href" is a valid qname, as is "foo:href". The prefix is optional in a QName. Here is the

Re: XML and namespaces

2005-11-30 Thread A.M. Kuchling
On 30 Nov 2005 07:22:56 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> quoted: > >>> element = document.createElementNS("DAV:", "href") This call is incorrect; the signature is createElementNS(namespaceURI, qualifiedName). If you call .createElementNS('whatever', 'DAV:href'), the o

Re: XML and namespaces

2005-11-30 Thread Roberto De Almeida
I've found the same bug. This is what I've been doing: from xml.dom.minidom import Document try: from xml.dom.ext import PrettyPrint except ImportError: PrettyPrint = None doc = Document() ... if PrettyPrint is not None: PrettyPrint(doc, stream=ou

Re: XML and namespaces

2005-11-30 Thread uche . ogbuji
Wilfredo Sánchez Vega: """ I'm having some issues around namespace handling with XML: >>> document = xml.dom.minidom.Document() >>> element = document.createElementNS("DAV:", "href") >>> document.appendChild(element) >>> document.toxml() '\n' """ I

XML and namespaces

2005-11-17 Thread Wilfredo Sánchez Vega
I'm having some issues around namespace handling with XML: >>> document = xml.dom.minidom.Document() >>> element = document.createElementNS("DAV:", "href") >>> document.appendChild(element) >>> document.toxml() '\n' Note that the namespace wa