Set<String> (final Set<String> namespaces, final String tagName, final XmlFile context) { if (tagName == null) { return namespaces; } final HashSet<String> set = new HashSet<>(); for (String namespace : namespaces) { final XmlFile xmlFile = XmlUtil.findNamespace(context, namespace); if (xmlFile != null) { final XmlDocument document = xmlFile.getDocument(); assert document != null; final XmlNSDescriptor nsDescriptor = (XmlNSDescriptor)document.getMetaData(); assert nsDescriptor != null; final XmlElementDescriptor[] elementDescriptors = nsDescriptor.getRootElementsDescriptors(document); for (XmlElementDescriptor elementDescriptor : elementDescriptors) { LOG.assertTrue(elementDescriptor != null, "Null returned from " + nsDescriptor); if (hasTag(elementDescriptor, tagName, new HashSet<>())) { set.add(namespace); break; } } } } return set; }