Filters the map of namespace prefix mappings to just those containing namespace URIs present in the model

@param model model
@param nsPrefixes map of namespace to uris
@return nsPrefixes filtered to namespaces found in the model
766270
private static Map<String, String> filterNamespacesToPresent(final Model model,
            final Map<String, String> nsPrefixes) {
        final Map<String, String> resultNses = new HashMap<>();
        final Set<Entry<String, String>> nsSet = nsPrefixes.entrySet();
        final NsIterator nsIt = model.listNameSpaces();
        while (nsIt.hasNext()) {
            final String ns = nsIt.next();

            final Optional<Entry<String, String>> nsOpt = nsSet.stream()
                    .filter(nsEntry -> nsEntry.getValue().equals(ns))
                    .findFirst();
            if (nsOpt.isPresent()) {
                final Entry<String, String> nsMatch = nsOpt.get();
                resultNses.put(nsMatch.getKey(), nsMatch.getValue());
            }
        }

        return resultNses;
    }
569703
function getPrefixFromNamespace($ns)
    {
        foreach ($this->namespaces as $p => $n) {
            if ($ns == $n || $ns == $p) {
                $this->usedNamespaces[$p] = $n;

                return $p;
            }
        }

        return FALSE;
    }
454221
def namespaces(*prefixes):
    
    namespaces = {}
    for prefix in prefixes:
        namespaces[prefix] = _nsmap[prefix]
    return namespaces
976395
@Override
	public void startPrefixMapping(String prefix, String uri)
			throws SAXException {
		this.exiAttributes.addNamespaceDeclaration(uri, prefix);
	}
117120
public void registerMapping(String prefix, String namespaceURI)
   {
      prefix2Ns.put(prefix, namespaceURI);
      ns2Prefix.put(namespaceURI, prefix);
   }
517516
public String lookupNamespace(final String prefix) {
        Object namespace = namespaceMap.get(prefix);
        if (namespace != null) {
            return namespace.toString();
        }
        return this.namespaceTagHints.isEmpty() ? prefix : this.namespaceTagHints.get(prefix);
    }
709082
public void clearDefaultPrefixes() {
		final Map<Integer, PrefixConfig> prefixConfigs = getPrefixConfigs();
		for (final PrefixConfig config : prefixConfigs.values()) {
			config.setDefaultPrefix(null);
		}
	}
592618
public String getPrefix(String namespaceURI)
    {
        String prefix = m_prefixMap.lookupPrefix(namespaceURI);
        return prefix;
    }
68937
protected static <R extends IPAddressSection> R[] getSpanningPrefixBlocks(
			R first,
			R other,
			UnaryOperator<R> getLower,
			UnaryOperator<R> getUpper,
			Comparator<R> comparator,
			UnaryOperator<R> prefixAdder,
			UnaryOperator<R> prefixRemover,
			IntFunction<R[]> arrayProducer) {
		first.checkSectionCount(other);
		R[] result = checkPrefixBlockContainment(first, other, prefixAdder, arrayProducer);
		if(result != null) {
			return result;
		}
		List<IPAddressSegmentSeries> blocks = getSpanningBlocks(first, other, getLower, getUpper, comparator, prefixRemover, IPAddressSection::splitIntoPrefixBlocks);
		result = blocks.toArray(arrayProducer.apply(blocks.size()));
		return result;
	}
1272888
private static void removePrefixFromChildren(Element el, String prefix)
			throws MarshalException {

		NodeList nl = el.getChildNodes();
		String localPrefix = null;
		for (int i = 0; i < nl.getLength(); i++) {
			Node n = nl.item(i);

			if (n.getNodeType() != Node.ELEMENT_NODE) {
				continue;
			}

			localPrefix = n.getPrefix();

			if (localPrefix != null && localPrefix.length() > 0) {

				if (!localPrefix.equals(prefix)) {
					IfmapJLog.warn("Extended Identifier: Multiple namespaces in extended identifer used."
							+ "IfmapJ thinks this is not a wise idea. Sorry!");
					throw new MarshalException("Extended Identifier: Multiple namespaces in extended identifer used."
							+ "IfmapJ thinks this is not a wise idea. Sorry!");
				}

				n.setPrefix(null);
			}

			removePrefixFromChildren((Element) n, prefix);
			dropNamespaceDecls((Element) n);

		}
	}
1025328
private List<MtasTokenString> getPrefixFilteredObjects(
      List<MtasTreeHit<?>> hits, List<String> prefixes) throws IOException {
    ArrayList<MtasTokenString> tokens = new ArrayList<>();
    IndexInput inObject = indexInputList.get("object");
    IndexInput inTerm = indexInputList.get("term");
    for (MtasTreeHit<?> hit : hits) {
      MtasTokenString token = MtasCodecPostingsFormat.getToken(inObject, inTerm,
          hit.ref);
      if (token != null) {
        if (prefixes != null && !prefixes.isEmpty()) {
          if (prefixes.contains(token.getPrefix())) {
            tokens.add(token);
          }
        } else {
          tokens.add(token);
        }
      }
    }
    return tokens;
  }
1071341
def refitPrefixes(self):
        
        for c in self.children:
            c.refitPrefixes()
        if self.prefix is not None:
            ns = self.resolvePrefix(self.prefix)
            if ns[1] is not None:
                self.expns = ns[1]
        self.prefix = None
        self.nsprefixes = {}
        return self
815914
def get_prefixes(self, ns_uri):
        """"""
        ni = self.__lookup_uri(ns_uri)
        return ni.prefixes.copy()
183762
def prefix_with_ns_if_necessary(name, name_ns, source_ns):
    # type: (typing.Text, ApiNamespace, ApiNamespace) -> typing.Text
    
    if source_ns == name_ns:
        return name
    return '{}.{}'.format(fmt_namespace(name_ns.name), name)
830961
public UnprotectedStringBuffer getNamespaceURI(CharSequence namespacePrefix) {
		for (ElementContext ctx : event.context) {
			for (Pair<UnprotectedStringBuffer, UnprotectedStringBuffer> ns : ctx.namespaces)
				if (ns.getValue1().equals(namespacePrefix))
					return ns.getValue2();
		}
		return new UnprotectedStringBuffer();
	}
494583
protected void addNamespaceContext() {
        NamespaceMap prefixmap = new NamespaceMap();
        NamespacePrefixList npl = getXsd().getNamespaceContext();
        if (npl == null) {
            /* We get an NPE if we don't add this. */
            prefixmap.add("", XMLConstants.W3C_XML_SCHEMA_NS_URI);
        } else {
            for (int i = 0; i < npl.getDeclaredPrefixes().length; i++) {
                prefixmap.add(npl.getDeclaredPrefixes()[i],
                        npl.getNamespaceURI(npl.getDeclaredPrefixes()[i]));
            }
        }
        prefixmap.add(getCOXBNamespacePrefix(), getCOXBNamespace());
        getXsd().setNamespaceContext(prefixmap);

    }
181851
def namespace_for_prefix(self, prefix):
        
        try:
            ni = self.__lookup_prefix(prefix)
        except PrefixNotFoundError:
            return None
        else:
            return ni.uri