[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: SAX2: Interning names in namespaces

  • From: Stefan Haustein <stefan.haustein@t...>
  • To: Terje Norderhaug <terje@i...>, xml-dev <xml-dev@x...>
  • Date: Sun, 06 Feb 2000 18:01:51 +0100

oop interning
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



Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.