W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2000

Re: Namespace treatment, cloning and node.supports

From: Dieter Köhler <dieter.koehler@ppp.uni-bamberg.de>
Date: Wed, 01 Mar 2000 23:21:09 +0100
Message-ID: <38BD97D5.AE5FF374@ppp.uni-bamberg.de>
To: keshlam@us.ibm.com, "www-dom@w3.org" <www-dom@w3.org>
> We've adopted the position stated by the namespace working group, that the
> prefix is only syntactic sugar and the namespace URI is the "real"
> information. The prefix is retained primarily as a hint to serialization
> routines, and is mutable because you may want to hint differently.
> [...] 
> There are folks who want to generate
> a DOM with only localnames and URIs, and assign prefixes as necessary
> during serialization. If we didn't allow qualified names to collide, they
> couldn't do so.

Nevertheless we should be more aware of XML-wellformedness, since
namespaces are semantic sugar on XML.  Your folks can do their
serialization by first using the URI as the prefix and then replacing
the prefix by a shorter version (Delphi example):

element.setAttributeNS('thisIsOurVeryVeryLongURI',
                       'thisIsOurVeryVeryLongURI:a',
                       'value');
...
// serialization
i:= 0;
while assigned(element.attributes.item(i)) do
  if element.attributes.item(i).prefix = 'thisIsOurVeryVeryLongURI' 
    then begin
      locName:= element.attributes.item(i).localName;
      qn:= 'shortPrefix:'+locName;
      vl:=  element.attributes.item(i).nodeValue;
      element.removeAttributeNode(element.attributes.item(i));
      element.setAttributeNS('thisIsOurVeryVeryLongURI',qn,vl);
      i:= 0;  // necessary, because we do not know what the 
              // implementation does with the index. Caching the 
              // attributes to be replaced could speed up this.
    end else inc(i);

The method I described can be used for every situation where you
prefer to operate with the "real information" before a serialization.
Just put the "real information" in the prefix and do everything that
is conformed with §5.3. of the XML Namespace REC which reads "... no
tag may contain two attribute which 1. have identical names, or 2.
have qualified names with the same local part and with prefixes which
have been bound to namespace names that are identical."   

> We do prevent the assignment of two attributes with the same localname/URI
> pair, of course, since those really are "the same attribute".

But that covers only (2) of the above cited §5.3. of the XML Namespace
REC.  I demand covering (1), too.  Beside the methods for namespace
treatment all operations on the DOM tree are as conservative as
possible by raising exceptions, if one tries to manipulate the
document tree in a way that violates its wellformedness. 
Unfortunately the namespace methods give up that principle for almost
no gain.

-- 
=====================================================================
 Dieter Koehler, M. A. - dieter.koehler@ppp.uni-bamberg.de
 Mittlere Kaulberg 22, D-96049 Bamberg, +49(0)951-5190726
 "http://www.philo.de/Philosophie-Seiten/": 1000+ Philosophie-Links
 "http://www.philo.de/VirtualLibrary/14.de.htm": Deutsche Philo-Links
 "http://www.philo.de/xml/": Open XML - XML-Komponenten fuer Delphi
=====================================================================
Received on Wednesday, 1 March 2000 17:23:07 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:47 GMT