def checkAttribute(elt, isIxElt, attrTag, attrValue): ixEltAttrDefs = ixAttrDefined.get(elt.namespaceURI, EMPTYDICT).get(elt.localName, ()) if attrTag.startswith("{"): ns, sep, localName = attrTag[1:].partition("}") else: ns = None localName = attrTag if ns is not None and ns not in XbrlConst.ixbrlAll and attrTag not in ixEltAttrDefs: if isIxElt: allowedNs = allowedNonIxAttrNS.get(elt.localName, None) if allowedNs != "##other" and ns != allowedNs: modelXbrl.error(ixMsgCode("qualifiedAttributeNotExpected", elt), _("Inline XBRL element %(element)s has qualified attribute %(name)s"), modelObject=elt, element=str(elt.elementQname), name=attrTag) if ns == XbrlConst.xbrli and elt.localName in { "fraction", "nonFraction", "nonNumeric", "references", "relationship", "tuple"}: modelXbrl.error(ixMsgCode("qualifiedAttributeDisallowed", elt), _("Inline XBRL element %(element)s has disallowed attribute %(name)s"), modelObject=elt, element=str(elt.elementQname), name=attrTag) else: if ns in XbrlConst.ixbrlAll: modelXbrl.error(ixMsgCode("inlineAttributeMisplaced", elt, name="other"), _("Inline XBRL attributes are not allowed on html elements: ix:%(name)s"), modelObject=elt, name=localName) elif ns not in {XbrlConst.xml, XbrlConst.xsi, XbrlConst.xhtml}: modelXbrl.error(ixMsgCode("extensionAttributeMisplaced", ns=_ixNS), _("Extension attributes are not allowed on html elements: %(tag)s"), modelObject=elt, tag=attrTag) elif isIxElt: try: _xsdType = ixAttrType[elt.namespaceURI][localName] if isinstance(_xsdType, dict): baseXsdType = _xsdType["type"] facets = _xsdType else: baseXsdType = _xsdType facets = None XmlValidate.validateValue(modelXbrl, elt, attrTag, baseXsdType, attrValue, facets=facets) if not (attrTag in ixEltAttrDefs or (localName in ixEltAttrDefs and (not ns or ns in XbrlConst.ixbrlAll))): raise KeyError disallowedXbrliAttrs = ({"scheme", "periodType", "balance", "contextRef", "unitRef", "precision", "decimals"} - {"fraction": {"contextRef", "unitRef"}, "nonFraction": {"contextRef", "unitRef", "decimals", "precision"}, "nonNumeric": {"contextRef"}}.get(elt.localName, set())) disallowedAttrs = set(a for a in disallowedXbrliAttrs if elt.get(a) is not None) if disallowedAttrs: modelXbrl.error(ixMsgCode("inlineElementAttributes",elt), _("Inline XBRL element %(element)s has disallowed attributes %(attributes)s"), modelObject=elt, element=elt.elementQname, attributes=", ".join(disallowedAttrs)) except KeyError: modelXbrl.error(ixMsgCode("attributeNotExpected",elt), _("Attribute %(attribute)s is not expected on element ix:%(element)s"), modelObject=elt, attribute=attrTag, element=elt.localName)
def checkAttribute(elt, isIxElt, attrTag, attrValue): if attrTag.startswith("{"): ns, sep, localName = attrTag[1:].partition("}") if isIxElt: allowedNs = nonIxAttrNS.get(elt.localName, None) if allowedNs != "##other" and ns != allowedNs: modelXbrl.error("ix:qualifiedAttributeNotExpected", _("Inline XBRL element %(element)s: has qualified attribute %(name)s"), modelObject=elt, element=str(elt.elementQname), name=attrTag) else: if ns in XbrlConst.ixbrlAll: modelXbrl.error("ix:inlineAttributeMisplaced", _("Inline XBRL attributes are not allowed on html elements: ix:%(name)s"), modelObject=elt, name=localName) elif ns not in {XbrlConst.xml, XbrlConst.xsi, XbrlConst.xhtml}: modelXbrl.error("ix:extensionAttributeMisplaced", _("Extension attributes are not allowed on html elements: %(tag)s"), modelObject=elt, tag=attrTag) elif isIxElt: try: _xsdType = ixAttrType[elt.namespaceURI][attrTag] if isinstance(_xsdType, dict): baseXsdType = _xsdType["type"] facets = _xsdType else: baseXsdType = _xsdType facets = None XmlValidate.validateValue(modelXbrl, elt, attrTag, baseXsdType, attrValue, facets=facets) disallowedXbrliAttrs = ({"scheme", "periodType", "balance", "contextRef", "unitRef", "precision", "decimals"} - {"fraction": {"contextRef", "unitRef"}, "nonFraction": {"contextRef", "unitRef", "decimals", "precision"}, "nonNumeric": {"contextRef"}}.get(elt.localName, set())) disallowedAttrs = [a for a in disallowedXbrliAttrs if elt.get(a) is not None] if disallowedAttrs: modelXbrl.error("ix:inlineElementAttributes", _("Inline XBRL element %(element)s has disallowed attributes %(attributes)s"), modelObject=elt, element=elt.elementQname, attributes=", ".join(disallowedAttrs)) except KeyError: modelXbrl.error("ix:attributeNotExpected", _("Attribute %(attribute)s is not expected on element element ix:%(element)s"), modelObject=elt, attribute=attrTag, element=elt.localName)
def checkAttribute(elt, isIxElt, attrTag, attrValue): if attrTag.startswith("{"): ns, sep, localName = attrTag[1:].partition("}") if isIxElt: if ns not in (XbrlConst.xml, XbrlConst.xsi): modelXbrl.error("ix:qualifiedAttributeNotExpected", _("Inline XBRL element %(element)s: has qualified attribute %(name)s"), modelObject=elt, element=str(elt.elementQname), name=attrTag) else: if ns in XbrlConst.ixbrlAll: modelXbrl.error("ix:inlineAttributeMisplaced", _("Inline XBRL attributes are not allowed on html elements: ix:%(name)s"), modelObject=elt, name=localName) elif ns not in {XbrlConst.xml, XbrlConst.xsi, XbrlConst.xhtml}: modelXbrl.error("ix:extensionAttributeMisplaced", _("Extension attributes are not allowed on html elements: %(tag)s"), modelObject=elt, tag=attrTag) elif isIxElt: try: _xsdType = ixAttrType[elt.namespaceURI][attrTag] if isinstance(_xsdType, dict): baseXsdType = _xsdType["type"] facets = _xsdType else: baseXsdType = _xsdType facets = None XmlValidate.validateValue(modelXbrl, elt, attrTag, baseXsdType, attrValue, facets=facets) disallowedXbrliAttrs = ({"scheme", "periodType", "balance", "contextRef", "unitRef", "precision", "decimals"} - {"fraction": {"contextRef", "unitRef"}, "nonFraction": {"contextRef", "unitRef", "decimals", "precision"}, "nonNumeric": {"contextRef"}}.get(elt.localName, set())) disallowedAttrs = [a for a in disallowedXbrliAttrs if elt.get(a) is not None] if disallowedAttrs: modelXbrl.error("ix:inlineElementAttributes", _("Inline XBRL element %(element)s has disallowed attributes %(attributes)s"), modelObject=elt, element=elt.elementQname, attributes=", ".join(disallowedAttrs)) except KeyError: modelXbrl.error("ix:attributeNotExpected", _("Attribute %(attribute)s is not expected on element element ix:%(element)s"), modelObject=elt, attribute=attrTag, element=elt.localName)