OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: SAX2: Interning names in namespaces

[ Lists Home | Date Index | Thread Index ]
  • From: Stefan Haustein <stefan.haustein@trantor.de>
  • To: Terje Norderhaug <terje@in-progress.com>, xml-dev <xml-dev@xml.org>
  • Date: Sun, 06 Feb 2000 18:01:51 +0100

Terje Norderhaug wrote:
> At 4:46 AM 2/5/00, Stefan Haustein wrote:
> > Terje Norderhaug wrote:

> >> I suggest that parsers interns each name as a separate string in the
> >> namespace it belong to. This should guarantee that two equal names in the
> >> same namespace are identical, and that two equal names in different
> >> namespaces are unidentical.
> >
> >Sounds too complicated for broad acceptance [...]
> It is straight-forward to implement. Here is pseudo code for one possible
> implementation using hash tables:

Ok, replace "complicated" by "unconvential". I do not like 
the idea off putting "hidden" meanings to string1 == string2. 
Normaly, someone unfamiliar with the concrete implemention 
would expect that both strings are java-interned. Also, you 
would not be able to compare just against a constant. You 
would need to ask the parser for the "right" String Object 
corresponding to a concrete namespace/name combination for 
comparison. My main argument (you did not qoute) was that 
I am in doubt if your suggestion is really good OOP. A 
cleaner OO approach would probably be having a QName class 
/ interface with the corresponding compare methods.
But we already had this discussion, and the conclusion 
was to stay at the String based interface. As far as I 
remember, the reasons were 

1. maximum performance / simplicity (SAX is a low level,
   driver-like interface)

2. there was no agreement about the semantics of equals 
   in several cases

> Given that names are interned in namespaces, one only have to test whether
> the two names are identical to determine whether the two names are the
> same:
>   name1 == name2
> Note that in the latter case, comparing namespaces are no longer required.
> This allows major simplifications of code as one no longer have to pass
> namespaces with names.

I do not agree: the problem is, you cannot any longer compare against
constants like 

 if (namespace.equals ("http://www.my.com/mynamespace")) {  
    if (name.equals ("price")) ....
    else if (name.equals ("quantity")) .....

you would need something like 

String myPriceElement = parser.getUnique
("http://www.my.com/mynamespace", "price");
String myQtytyElement = parser.getUnique
("http://www.my.com/mynamespace", "quantity");

  if (name == myPriceElement) ....
  else if (name == myQtytyElement) ....

... thus add a lot of variables or even worse, do the hashtable lookup

Best regards



News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS