[XML-SIG] SAX 2.0 names

Lars Marius Garshol larsga@garshol.priv.no
29 Feb 2000 08:21:44 +0100

I've done some more thinking about this now, and this is the result:

Element and attribute type names in XML have the following properties:

 - a namespace URI
 - a local name
 - a raw name (SAX 2.0b2 is now reporting this instead of the prefix)

The essential operations on these names are:

 - comparison
 - indexing (that is, using them as keys in a dictionary)
 - decomposition (which includes partial comparison, where you check
   only the namespace or local name of the name)

After the discussions we've had so far, these are the best
alternatives for representations I can think of:

 - as objects (with __cmp__, __hash__, get_uri, get_local_name and
   get_rawname methods)

   - requires a bit of machinery in drivers to be effective
   - all operations will be slow
   - a natural way to model this

 - as strings (of the form 'uri localname', with the rawname in a
   separate parameter)

   - comparison and indexing will be fast, especially with interned
   - decomposition will be slow and awkward
   - feels kind of like a hack

 - as tuples (of the form ('uri', 'localname'), with the rawname in a
   separate parameter)

   - all operations are convenient
   - comparison and indexing may not be as fast as with strings
   - a natural way to model this

I have to go to a meeting before too long, but I'll try to make two
benchmarks to compare the performance of the different representations.

--Lars M.