Get xml ns prefix. self.nsMap must be set
18342
def _NSPrefix(self, ns):
      
      if ns == self.defaultNS:
         return ''
      prefix = self.nsMap[ns]
      return prefix and prefix + ':' or ''
742743
def add_prefixes(self, nsmap: Dict[str, Namespace]) -> None:
        
        [self._g.bind(e[0], e[1]) for e in nsmap.items()]
16168
public static nsxmlnamespace[] get(nitro_service service, String prefix[]) throws Exception{
		if (prefix !=null && prefix.length>0) {
			nsxmlnamespace response[] = new nsxmlnamespace[prefix.length];
			nsxmlnamespace obj[] = new nsxmlnamespace[prefix.length];
			for (int i=0;i<prefix.length;i++) {
				obj[i] = new nsxmlnamespace();
				obj[i].set_prefix(prefix[i]);
				response[i] = (nsxmlnamespace) obj[i].get_resource(service);
			}
			return response;
		}
		return null;
	}
352218
def _QName(self, typ, defNS):
      
      attr = ''
      ns, name = GetQualifiedWsdlName(typ)
      if ns == defNS:
         prefix = ''
      else:
         try:
            prefix = self.nsMap[ns]
         except KeyError:
            # We have not seen this ns before
            prefix = ns.split(':', 1)[-1]
            attr = ' xmlns:{0}="{1}"'.format(prefix, ns)
      return attr, prefix and prefix + ':' + name or name
154580
def qtag(tag):
    
    prefix, tagroot = tag.split(':')
    uri = nsmap[prefix]
    return '{%s}%s' % (uri, tagroot)
1136683
def xpath(self, xpath_str):
        
        return super(BaseOxmlElement, self).xpath(
            xpath_str, namespaces=nsmap
        )
346962
def xpathVariableLookupNS(self, name, ns_uri):
        
        ret = libxml2mod.xmlXPathVariableLookupNS(self._o, name, ns_uri)
        if ret is None:raise xpathError('xmlXPathVariableLookupNS() failed')
        return xpathObjectRet(ret)
1114992
def _getPrefix(self, node, nsuri):
        '''
        
        '''
        try:
            if node and (node.nodeType == node.ELEMENT_NODE) and \
                (nsuri == self._dom.findDefaultNS(node)):
                return None
        except DOMException, ex:
            pass
        if nsuri == XMLNS.XML:
            return self._xml_prefix
        if node.nodeType == Node.ELEMENT_NODE:
            for attr in node.attributes.values():
                if attr.namespaceURI == XMLNS.BASE \
                   and nsuri == attr.value:
                        return attr.localName
            else:
                if node.parentNode:
                    return self._getPrefix(node.parentNode, nsuri)
        raise NamespaceError, 'namespaceURI "%s" is not defined' %nsuri
991856
public static String getPrefixFromXMLNSDecl(String attRawName)
  {

    int index = attRawName.indexOf(':');

    return (index >= 0) ? attRawName.substring(index + 1) : "";
  }
38071
def update_xml_element(self):
        

        if not hasattr(self, 'xml_element'):
            self.xml_element = etree.Element(self.name, nsmap=NSMAP)

        self.xml_element.set('system', str(self.system))
        self.xml_element.text = self.text

        return self.xml_element
216218
def update_xml_element(self):
        

        if not hasattr(self, 'xml_element'):
            self.xml_element = etree.Element(self.name, nsmap=NSMAP)

        if hasattr(self, 'time'):
            self.xml_element.set('time', self.time_to_str())
        if hasattr(self, 'update'):
            self.xml_element.set('update', str(self.update))
        self.xml_element.text = self.text

        return self.xml_element
78819
@Override
    public void writeNamespace(String prefix, String nsURI) throws XMLStreamException
    {
        if (prefix == null || prefix.length() == 0) {
            writeDefaultNamespace(nsURI);
            return;
        }
        if (!mNsAware) {
            throwOutputError("Can not write namespaces with non-namespace writer.");
        }
        outputAttribute(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns", prefix, nsURI);
        mCurrElem.addPrefix(prefix, nsURI);
    }
1025128
@Override
  public Iterator<String> getPrefixes(String namespaceURI) {
    // per javax.xml.namespace.NamespaceContext doc
    if (namespaceURI == null)
      throw new IllegalArgumentException("Cannot find prefix for null namespace URI");

    List<String> list = new ArrayList<>();
    if (XMLConstants.XML_NS_URI.equals(namespaceURI))
      list.add(XMLConstants.XML_NS_PREFIX);
    else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI))
      list.add(XMLConstants.XMLNS_ATTRIBUTE);
    else
      for (Map.Entry<String, String> entry: bindings.entrySet()) {
        if (namespaceURI.equals(entry.getValue()))
          list.add(entry.getKey());
      }

    return Collections.unmodifiableList(list).iterator();
  }
1328795
def updateObjectFromXML(xml_doc, obj, mapping):
    
    nsmap = None
    if isinstance(mapping, dict):
        # The special key @namespaces is used to pass
        # namespaces and prefix mappings for xpath selectors.
        # e.g. {'x': 'http://example.com/namespace'}
        if '@namespaces' in mapping:
            nsmap = mapping['@namespaces']
    else:
        raise TypeError('Tag-to-property map must be a dict.')
    # Iterate over the keys of the translation dictionary from event objects
    # to xml objects, so we can update the fields with the new information
    for k, v in mapping.items():
        if k.startswith('@'):
            continue
        selected_text = None
        if isinstance(v, basestring):
            selector = v
        elif isinstance(v, list):
            selector = '/'.join(v)
        else:
            raise TypeError(
                'Invalid tag-to-property mapping dict: '
                'values must be strings or lists, not %s.' % (type(v),)
            )
        try:
            selected_text = xml_doc.xpath(selector, namespaces=nsmap)
            if isinstance(selected_text, list):
                selected_text = selected_text[0]
            selected_text = selected_text.text
            setattr(obj, k, selected_text)
        except IndexError:
            # Assume the value is missing. It's also possible that the
            # given selector is valid but wrong, but the more common
            # case is that the element is missing. To be consistent with
            # the prior implementation, empty resultsets just mean empty
            # attributes.
            continue
    return obj
950027
def LookupNamespace(self, prefix):
        
        ret = libxml2mod.xmlTextReaderLookupNamespace(self._o, prefix)
        return ret
982492
public java.lang.String getXmlns() {
        return (java.lang.String) getStateHelper().eval(PropertyKeys.xmlns);

    }
963470
def update_xml_element(self):
        

        if not hasattr(self, 'xml_element'):
            self.xml_element = etree.Element(self.name, nsmap=NSMAP)

        if hasattr(self, 'date'):
            self.xml_element.set('date', self.date)
        self.xml_element.text = self.text

        return self.xml_element