Ejemplo n.º 1
0
 def register_namespace(self, prefix, uri):
     """Registers a namespace,, making it available for use when adding subsequent fields to the entry.
     
     Registration will also affect the XML export, adding in the xmlns:prefix="url" attribute when required."""
     etree.register_namespace(prefix, uri)
     self.add_ns.append(prefix)
     if prefix not in NS.keys():
         NS[prefix] = "{%s}%%s" % uri
Ejemplo n.º 2
0
    def register_namespace(self, prefix, uri):
        """Registers a namespace,, making it available for use when adding subsequent fields to the entry.
        
        Registration will also affect the XML export, adding in the xmlns:prefix="url" attribute when required."""
        try:
            etree.register_namespace(prefix, uri)
        except AttributeError as e:
            # the etree implementation we're using doesn't support register_namespace
            # (probably lxml)
            pass
        self.add_ns.append(prefix)
        if prefix not in NS.keys():
            NS[prefix] = "{%s}%%s" % uri

        # we also have to handle namespaces internally, for etree implementations which
        # don't support register_namespace
        if prefix not in self.nsmap.keys():
            self.nsmap[prefix] = uri
Ejemplo n.º 3
0
 def register_namespace(self, prefix, uri):
     """Registers a namespace,, making it available for use when adding subsequent fields to the entry.
     
     Registration will also affect the XML export, adding in the xmlns:prefix="url" attribute when required."""
     try:
         etree.register_namespace(prefix, uri)
     except AttributeError as e:
         # the etree implementation we're using doesn't support register_namespace
         # (probably lxml)
         pass
     self.add_ns.append(prefix)
     if prefix not in NS.keys():
         NS[prefix] = "{%s}%%s" % uri
         
     # we also have to handle namespaces internally, for etree implementations which
     # don't support register_namespace
     if prefix not in self.nsmap.keys():
         self.nsmap[prefix] = uri