

def checkDTSdocument(val, modelDocument, isFilingDocument):
    for (hrefElt, _hrefedDoc, hrefId) in modelDocument.hrefObjects:
        if hrefId:
            for (scheme, _path) in XmlUtil.xpointerSchemes(hrefId):
                if ((scheme == 'element') and val.validateDisclosureSystem):
                    val.modelXbrl.error(('EFM.6.03.06', 'GFM.1.01.03'), _('Href %(elementHref)s may only have shorthand xpointers'), modelObject=hrefElt, elementHref=hrefElt.get('{http://www.w3.org/1999/xlink}href'))
    if (not isFilingDocument):
        return
    if (modelDocument.type == ModelDocument.Type.SCHEMA):
        if ((modelDocument.targetNamespace is not None) and (len(modelDocument.targetNamespace) > 85)):
            l = len(modelDocument.targetNamespace.encode('utf-8'))
            if (l > 255):
                val.modelXbrl.error('EFM.6.07.30', _('Schema targetNamespace length (%(length)s) is over 255 bytes long in utf-8 %(targetNamespace)s'), modelObject=modelDocument.xmlRootElement, length=l, targetNamespace=modelDocument.targetNamespace, value=modelDocument.targetNamespace)
    if (modelDocument.type in (ModelDocument.Type.SCHEMA, ModelDocument.Type.LINKBASE)):
        isSchema = (modelDocument.type == ModelDocument.Type.SCHEMA)
        if isSchema:
            for elt in modelDocument.xmlRootElement.iter(tag='{http://www.w3.org/2001/XMLSchema}*'):
                if (elt.namespaceURI == XbrlConst.xsd):
                    localName = elt.localName
                    if (localName in {'element', 'complexType', 'simpleType'}):
                        name = elt.get('name')
                        if (name and (len(name) > 64)):
                            l = len(name.encode('utf-8'))
                            if (l > 200):
                                val.modelXbrl.error('EFM.6.07.29', _('Schema %(element)s has a name length (%(length)s) over 200 bytes long in utf-8, %(name)s.'), modelObject=elt, element=localName, name=name, length=l)
    for elt in modelDocument.xmlRootElement.iter():
        if isinstance(elt, ModelObject):
            xlinkType = elt.get('{http://www.w3.org/1999/xlink}type')
            xlinkRole = elt.get('{http://www.w3.org/1999/xlink}role')
            if (elt.namespaceURI == XbrlConst.link):
                if (elt.localName in ('roleType', 'arcroleType')):
                    uriAttr = {
                        'roleType': 'roleURI',
                        'arcroleType': 'arcroleURI',
                    }[elt.localName]
                    roleURI = elt.get(uriAttr)
                    if (len(roleURI) > 85):
                        l = len(elt.encode('utf-8'))
                        if (l > 255):
                            val.modelXbrl.error('EFM.6.07.30', _('Schema %(element)s %(attribute)s length (%(length)s) is over 255 bytes long in utf-8 %(roleURI)s'), modelObject=elt, element=elt.qname, attribute=uriAttr, length=l, roleURI=roleURI, value=roleURI)
                if (elt.localName == 'arcroleRef'):
                    refUri = elt.get('arcroleURI')
                    hrefAttr = elt.get('{http://www.w3.org/1999/xlink}href')
                    (hrefUri, hrefId) = UrlUtil.splitDecodeFragment(hrefAttr)
                    if (hrefUri not in val.disclosureSystem.standardTaxonomiesDict):
                        val.modelXbrl.error(('EFM.6.09.06', 'GFM.1.04.06'), _('Arcrole %(refURI)s arcroleRef %(xlinkHref)s must be a standard taxonomy'), modelObject=elt, refURI=refUri, xlinkHref=hrefUri)
            if ((modelDocument.type == ModelDocument.Type.INLINEXBRL) and (elt.namespaceURI in XbrlConst.ixbrlAll)):
                if (elt.localName == 'footnote'):
                    if val.validateGFM:
                        if (elt.get('{http://www.w3.org/1999/xlink}arcrole') != XbrlConst.factFootnote):
                            if (not any((inlineDisplayNonePattern.search((e.get('style') or '')) for e in XmlUtil.ancestors(elt, XbrlConst.xhtml, 'div')))):
                                val.modelXbrl.error(('EFM.N/A', 'GFM:1.10.16'), _('Inline XBRL footnote %(footnoteID)s must be in non-displayable div due to arcrole %(arcrole)s'), modelObject=elt, footnoteID=elt.get('footnoteID'), arcrole=elt.get('{http://www.w3.org/1999/xlink}arcrole'))
                        if (not elt.get('{http://www.w3.org/XML/1998/namespace}lang')):
                            val.modelXbrl.error(('EFM.N/A', 'GFM:1.10.13'), _('Inline XBRL footnote %(footnoteID)s is missing an xml:lang attribute'), modelObject=elt, footnoteID=id)
            if (xlinkType == 'extended'):
                if ((not xlinkRole) or (xlinkRole == '')):
                    val.modelXbrl.error(('EFM.6.09.04', 'GFM.1.04.04'), '%(element)s is missing an xlink:role', modelObject=elt, element=elt.qname)
                if (not val.extendedElementName):
                    val.extendedElementName = elt.qname
                elif (val.extendedElementName != elt.qname):
                    val.modelXbrl.error(('EFM.6.09.07', 'GFM:1.04.07'), _('Extended element %(element)s must be the same as %(element2)s'), modelObject=elt, element=elt.qname, element2=val.extendedElementName)
            elif (xlinkType == 'resource'):
                if (not xlinkRole):
                    val.modelXbrl.error(('EFM.6.09.04', 'GFM.1.04.04'), _('%(element)s is missing an xlink:role'), modelObject=elt, element=elt.qname)
                elif (not XbrlConst.isStandardRole(xlinkRole)):
                    modelsRole = val.modelXbrl.roleTypes.get(xlinkRole)
                    if ((modelsRole is None) or (len(modelsRole) == 0) or (modelsRole[0].modelDocument.targetNamespace not in val.disclosureSystem.standardTaxonomiesDict)):
                        val.modelXbrl.error(('EFM.6.09.05', 'GFM.1.04.05'), _('Resource %(xlinkLabel)s role %(role)s is not a standard taxonomy role'), modelObject=elt, xlinkLabel=elt.get('{http://www.w3.org/1999/xlink}label'), role=xlinkRole, element=elt.qname, roleDefinition=val.modelXbrl.roleTypeDefinition(xlinkRole))
            elif (xlinkType == 'arc'):
                if (elt.get('priority') is not None):
                    priority = elt.get('priority')
                    try:
                        if (int(priority) >= 10):
                            val.modelXbrl.error(('EFM.6.09.09', 'GFM.1.04.08'), _('Arc from %(xlinkFrom)s to %(xlinkTo)s priority %(priority)s must be less than 10'), modelObject=elt, arcElement=elt.qname, xlinkFrom=elt.get('{http://www.w3.org/1999/xlink}from'), xlinkTo=elt.get('{http://www.w3.org/1999/xlink}to'), priority=priority)
                    except ValueError:
                        val.modelXbrl.error(('EFM.6.09.09', 'GFM.1.04.08'), _('Arc from %(xlinkFrom)s to %(xlinkTo)s priority %(priority)s is not an integer'), modelObject=elt, arcElement=elt.qname, xlinkFrom=elt.get('{http://www.w3.org/1999/xlink}from'), xlinkTo=elt.get('{http://www.w3.org/1999/xlink}to'), priority=priority)
                if (elt.namespaceURI == XbrlConst.link):
                    if ((elt.localName == 'presentationArc') and (not elt.get('order'))):
                        val.modelXbrl.error(('EFM.6.12.01', 'GFM.1.06.01'), _('PresentationArc from %(xlinkFrom)s to %(xlinkTo)s must have an order'), modelObject=elt, xlinkFrom=elt.get('{http://www.w3.org/1999/xlink}from'), xlinkTo=elt.get('{http://www.w3.org/1999/xlink}to'), conceptFrom=arcFromConceptQname(elt), conceptTo=arcToConceptQname(elt))
                    elif (elt.localName == 'calculationArc'):
                        if (not elt.get('order')):
                            val.modelXbrl.error(('EFM.6.14.01', 'GFM.1.07.01'), _('CalculationArc from %(xlinkFrom)s to %(xlinkTo)s must have an order'), modelObject=elt, xlinkFrom=elt.get('{http://www.w3.org/1999/xlink}from'), xlinkTo=elt.get('{http://www.w3.org/1999/xlink}to'), conceptFrom=arcFromConceptQname(elt), conceptTo=arcToConceptQname(elt))
                        try:
                            weightAttr = elt.get('weight')
                            weight = float(weightAttr)
                            if (not (weight in (1, (- 1)))):
                                val.modelXbrl.error(('EFM.6.14.02', 'GFM.1.07.02'), _('CalculationArc from %(xlinkFrom)s to %(xlinkTo)s weight %(weight)s must be 1 or -1'), modelObject=elt, xlinkFrom=elt.get('{http://www.w3.org/1999/xlink}from'), xlinkTo=elt.get('{http://www.w3.org/1999/xlink}to'), conceptFrom=arcFromConceptQname(elt), conceptTo=arcToConceptQname(elt), weight=weightAttr)
                        except ValueError:
                            val.modelXbrl.error(('EFM.6.14.02', 'GFM.1.07.02'), _('CalculationArc from %(xlinkFrom)s to %(xlinkTo)s must have an weight (value error in "%(weight)s")'), modelObject=elt, xlinkFrom=elt.get('{http://www.w3.org/1999/xlink}from'), xlinkTo=elt.get('{http://www.w3.org/1999/xlink}to'), conceptFrom=arcFromConceptQname(elt), conceptTo=arcToConceptQname(elt), weight=weightAttr)
                    elif (elt.localName == 'definitionArc'):
                        if (not elt.get('order')):
                            val.modelXbrl.error(('EFM.6.16.01', 'GFM.1.08.01'), _('DefinitionArc from %(xlinkFrom)s to %(xlinkTo)s must have an order'), modelObject=elt, xlinkFrom=elt.get('{http://www.w3.org/1999/xlink}from'), xlinkTo=elt.get('{http://www.w3.org/1999/xlink}to'), conceptFrom=arcFromConceptQname(elt), conceptTo=arcToConceptQname(elt))

dataset/ETHPy150Open Arelle/Arelle/arelle/plugin/validate/EFM/Document.py checkDTSdocument/VarMisuse@503/870 `roleURI`->`elt`