Changeset 3157:c0fa5e1a104c in livinglogic.python.xist

Show
Ignore:
Timestamp:
01/17/08 22:40:43 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Do the check for the xml namespace first.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/publishers.py

    r3156 r3157  
    183183        if xmlns is None: 
    184184            return None 
    185         emptyok = isinstance(object, xsc.Element) # If it's e.g. a procinst assume we need a non-empty prefix 
    186         try: 
    187             prefix = self._ns2prefix[xmlns] 
    188         except KeyError: # A namespace we haven't encountered yet 
    189             if xmlns == xsc.xml_xmlns: # We don't need a namespace mapping for the xml namespace 
    190                 prefix = "xml" 
    191             else: 
     185        if xmlns == xsc.xml_xmlns: # We don't need a namespace mapping for the xml namespace 
     186            prefix = "xml" 
     187        else: 
     188            emptyok = isinstance(object, xsc.Element) # If it's e.g. a procinst assume we need a non-empty prefix 
     189            try: 
     190                prefix = self._ns2prefix[xmlns] 
     191            except KeyError: # A namespace we haven't encountered yet 
    192192                prefix = self.prefixes.get(xmlns, self.prefixdefault) 
    193193                # global attributes always require prefixed names 
     
    205205                    self._ns2prefix[xmlns] = prefix 
    206206                    self._prefix2ns[prefix] = xmlns 
    207         else: 
    208             # We can't use the unprefixed names for global attributes 
    209             if (prefix is None or prefix is False) and not emptyok: 
    210                 # Use a new one 
    211                 prefix = self._newprefix() 
    212                 self._ns2prefix[xmlns] = prefix 
    213                 self._prefix2ns[prefix] = xmlns 
     207            else: 
     208                # We can't use the unprefixed names for global attributes 
     209                if (prefix is None or prefix is False) and not emptyok: 
     210                    # Use a new one 
     211                    prefix = self._newprefix() 
     212                    self._ns2prefix[xmlns] = prefix 
     213                    self._prefix2ns[prefix] = xmlns 
    214214        return prefix 
    215215