def addFacets(thisDoc, restrElt, facets):
    if facets:
        excludedEnumeration = facets.get('excludedEnumeration')
        if ((annotateEnumerationsDocumentation and (excludedEnumeration == 'X')) or (excludedEnumeration == 'D')):
            for (facet, facetValue) in facets.items():
                if (facet == 'enumeration'):
                    enumerationsDocumentation = []
                    for valLbl in facetValue.split('\n'):
                        (val, _sep, _label) = valLbl.partition('=')
                        val = val.strip()
                        if len(val):
                            if (val == '(empty)'):
                                val = ''
                            _label = _label.strip()
                            enumerationsDocumentation.append(('{}: {}'.format(val, _label) if _label else val))
                    XmlUtil.addChild(XmlUtil.addChild(restrElt, XbrlConst.xsd, 'annotation'), XbrlConst.xsd, 'documentation', text=' \n'.join(enumerationsDocumentation))
        for (facet, facetValue) in sorted(facets.items(), key=(lambda i: facetSortOrder.get(i[0], i[0]))):
            if (facet == 'enumeration'):
                if ((not annotateEnumerationsDocumentation) and (not excludedEnumeration)):
                    for valLbl in facetValue.split('\n'):
                        (val, _sep, _label) = valLbl.partition('=')
                        val = val.strip()
                        _label = _label.strip()
                        if len(val):
                            if (val == '(empty)'):
                                val = ''
                            _attributes = {'value': val}
                            if _label:
                                _labelsByLang = None
                                if (_label.startswith('{') and _label.endswith('}')):
                                    try:
                                        _labelsByLang = json.loads(_label)
                                    except json.decoder.JSONDecodeError:
                                        _labelsByLang = None
                                _name = 'enum{}'.format(_enumNum[0])
                                _attributes['id'] = ((thisDoc.extensionSchemaPrefix + '_') + _name)
                                _enumNum[0] += 1
                                if _labelsByLang:
                                    for (_lang, _langLabel) in _labelsByLang.items():
                                        thisDoc.extensionLabels[(thisDoc.extensionSchemaPrefix, _name, _lang, XbrlConst.genStandardLabel)] = _langLabel
                                else:
                                    thisDoc.extensionLabels[(thisDoc.extensionSchemaPrefix, _name, defaultLabelLang, XbrlConst.genStandardLabel)] = _label
                            enumElt = XmlUtil.addChild(restrElt, XbrlConst.xsd, facet, attributes=_attributes)
                            if (thisDoc.hasEnumerationDocumentation and _label):
                                if _labelsByLang:
                                    annotationElt = XmlUtil.addChild(enumElt, XbrlConst.xsd, 'annotation')
                                    for (_lang, _langLabel) in _labelsByLang.items():
                                        thisDoc.extensionLabels[(thisDoc.extensionSchemaPrefix, _name, _lang, XbrlConst.genStandardLabel)] = _langLabel
                                        XmlUtil.addChild(annotationElt, XbrlConst.xsd, 'documentation', text=_langLabel, attributes={'{http://www.w3.org/XML/1998/namespace}lang': _lang})
                                else:
                                    XmlUtil.addChild(XmlUtil.addChild(enumElt, XbrlConst.xsd, 'annotation'), XbrlConst.xsd, 'documentation', text=_label)
            elif (facet != 'excludedEnumeration'):
                XmlUtil.addChild(restrElt, XbrlConst.xsd, facet, attributes={'value': str(facetValue)})
def addFacets(thisDoc, restrElt, facets):
    if facets:
        excludedEnumeration = facets.get('excludedEnumeration')
        if ((annotateEnumerationsDocumentation and (excludedEnumeration == 'X')) or (excludedEnumeration == 'D')):
            for (facet, facetValue) in facets.items():
                if (facet == 'enumeration'):
                    enumerationsDocumentation = []
                    for valLbl in facetValue.split('\n'):
                        (val, _sep, _label) = valLbl.partition('=')
                        val = val.strip()
                        if len(val):
                            if (val == '(empty)'):
                                val = 
                            _label = _label.strip()
                            enumerationsDocumentation.append(('{}: {}'.format(val, _label) if _label else val))
                    XmlUtil.addChild(XmlUtil.addChild(restrElt, XbrlConst.xsd, 'annotation'), XbrlConst.xsd, 'documentation', text=' \n'.join(enumerationsDocumentation))
        for (facet, facetValue) in sorted(facets.items(), key=(lambda i: facetSortOrder.get(i[0], i[0]))):
            if (facet == 'enumeration'):
                if ((not annotateEnumerationsDocumentation) and (not excludedEnumeration)):
                    for valLbl in facetValue.split('\n'):
                        (val, _sep, _label) = valLbl.partition('=')
                        val = val.strip()
                        _label = _label.strip()
                        if len(val):
                            if (val == '(empty)'):
                                val = 
                            _attributes = {'value': val}
                            if _label:
                                _labelsByLang = None
                                if (_label.startswith('{') and _label.endswith('}')):
                                    try:
                                        _labelsByLang = json.loads(_label)
                                    except json.decoder.JSONDecodeError:
                                        _labelsByLang = None
                                _name = 'enum{}'.format(_enumNum[0])
                                _attributes['id'] = ((thisDoc.extensionSchemaPrefix + '_') + _name)
                                _enumNum[0] += 1
                                if _labelsByLang:
                                    for (_lang, _langLabel) in _labelsByLang.items():
                                        thisDoc.extensionLabels[(thisDoc.extensionSchemaPrefix, _name, _lang, XbrlConst.genStandardLabel)] = _langLabel
                                else:
                                    thisDoc.extensionLabels[(thisDoc.extensionSchemaPrefix, _name, defaultLabelLang, XbrlConst.genStandardLabel)] = _label
                            enumElt = XmlUtil.addChild(restrElt, XbrlConst.xsd, facet, attributes=_attributes)
                            if (thisDoc.hasEnumerationDocumentation and _label):
                                if _labelsByLang:
                                    annotationElt = XmlUtil.addChild(enumElt, XbrlConst.xsd, 'annotation')
                                    for (_lang, _langLabel) in _labelsByLang.items():
                                        thisDoc.extensionLabels[(thisDoc.extensionSchemaPrefix, _name, _lang, XbrlConst.genStandardLabel)] = _langLabel
                                        XmlUtil.addChild(annotationElt, XbrlConst.xsd, 'documentation', text=_langLabel, attributes={'{http://www.w3.org/XML/1998/namespace}lang': _lang})
                                else:
                                    XmlUtil.addChild(XmlUtil.addChild(enumElt, XbrlConst.xsd, 'annotation'), XbrlConst.xsd, 'documentation', text=_label)
            elif (facet != 'excludedEnumeration'):
                XmlUtil.addChild(restrElt, XbrlConst.xsd, facet, attributes={'value': str(facetValue)})