XmlTag (final String text, XmlTag tag) { final Ref<XmlTag> enumerationTag = new Ref<>(); Processor<XmlTag> processor = xmlTag -> { if (text.equals(xmlTag.getAttributeValue(XmlUtil.VALUE_ATTR_NAME))) { enumerationTag.set(xmlTag); } return true; }; XmlUtil.processEnumerationValues(tag, processor); if (enumerationTag.get() == null) { final XmlElementDescriptorImpl elementDescriptor = (XmlElementDescriptorImpl)XmlUtil.findXmlDescriptorByType( tag, null ); TypeDescriptor type = elementDescriptor != null ? elementDescriptor.getType():null; if (type instanceof ComplexTypeDescriptor) { XmlUtil.processEnumerationValues(((ComplexTypeDescriptor)type).getDeclaration(), processor); } } return enumerationTag.get(); }