Skip to content

Commit

Permalink
inline cleanup:
Browse files Browse the repository at this point in the history
  preserve id attribute on footnotes (for #footnote loc)
  fix crash on badly messed up fact qnames
  footnotes with inter-ELR resource locs
  additional checks not aware of 1.1 namespace
  • Loading branch information
Herm Fischer authored and Herm Fischer committed Jun 15, 2015
1 parent 6686e17 commit 8d31353
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 2 additions & 0 deletions arelle/ModelInstanceObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,8 @@ def attributes(self):
attributes = {"{http://www.w3.org/1999/xlink}type":"resource",
"{http://www.w3.org/1999/xlink}label":self.xlinkLabel,
"{http://www.w3.org/1999/xlink}role": self.role}
if self.id:
attributes["id"] = self.id
lang = self.xmlLang
if lang:
attributes["{http://www.w3.org/XML/1998/namespace}lang"] = lang
Expand Down
10 changes: 5 additions & 5 deletions arelle/ValidateFiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ def validate(self, modelXbrl, parameters=None):
contextIDs.discard(factContextID)

context = f.context
factInDeiNamespace = None
factQname = f.qname # works for both inline and plain instances
factElementName = factQname.localName
if disclosureSystem.deiNamespacePattern is not None:
factInDeiNamespace = disclosureSystem.deiNamespacePattern.match(factQname.namespaceURI)
else:
factInDeiNamespace = None
if factQname: # may be none in error situations
factElementName = factQname.localName
if disclosureSystem.deiNamespacePattern is not None:
factInDeiNamespace = disclosureSystem.deiNamespacePattern.match(factQname.namespaceURI)
# standard dei items from required context
if context is not None: # tests do not apply to tuples
if not context.hasSegment and not context.hasScenario:
Expand Down
10 changes: 6 additions & 4 deletions arelle/ValidateXbrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from arelle.ModelInstanceObject import ModelInlineFact
from arelle.ModelValue import qname
from arelle.PluginManager import pluginClassMethods
from arelle.XbrlConst import ixbrlAll
from arelle.XmlValidate import VALID
from collections import defaultdict
validateUniqueParticleAttribution = None # dynamic import
Expand Down Expand Up @@ -378,7 +379,7 @@ def validate(self, modelXbrl, parameters=None):
ixdsIdObjects = defaultdict(list)
for ixdsDoc in self.ixdsDocs:
for idObject in ixdsDoc.idObjects.values():
if idObject.namespaceURI in XbrlConst.ixbrlAll or idObject.elementQname in (XbrlConst.qnXbrliContext, XbrlConst.qnXbrliUnit):
if idObject.namespaceURI in ixbrlAll or idObject.elementQname in (XbrlConst.qnXbrliContext, XbrlConst.qnXbrliUnit):
ixdsIdObjects[idObject.id].append(idObject)
for _id, objs in ixdsIdObjects.items():
if len(objs) > 1:
Expand Down Expand Up @@ -468,15 +469,15 @@ def validate(self, modelXbrl, parameters=None):
for ixRel in self.ixdsRelationships:
for fromRef in ixRel.get("fromRefs","").split():
refs = ixdsIdObjects.get(fromRef)
if refs is None or refs[0].namespaceURI != ixRel or refs[0].localName not in ("fraction", "nonFraction", "nonNumeric", "tuple"):
if refs is None or refs[0].namespaceURI not in ixbrlAll or refs[0].localName not in ("fraction", "nonFraction", "nonNumeric", "tuple"):
modelXbrl.error("ix:relationshipFromRef",
_("Inline XBRL fromRef %(ref)s is not a fraction, ix:nonFraction, ix:nonNumeric or ix:tuple."),
modelObject=ixRel, ref=fromRef)
hasFootnoteToRef = None
hasToRefMixture = False
for toRef in ixRel.get("toRefs","").split():
refs = ixdsIdObjects.get(fromRef)
if refs is None or refs[0].namespaceURI != ixRel or refs[0].localName not in ("footnote", "fraction", "nonFraction", "nonNumeric", "tuple"):
if refs is None or refs[0].namespaceURI not in ixbrlAll or refs[0].localName not in ("footnote", "fraction", "nonFraction", "nonNumeric", "tuple"):
modelXbrl.error("ix:relationshipToRef",
_("Inline XBRL fromRef %(ref)s is not a footnote, fraction, ix:nonFraction, ix:nonNumeric or ix:tuple."),
modelObject=ixRel, ref=fromRef)
Expand Down Expand Up @@ -581,7 +582,8 @@ def checkLinks(self, modelLinks):
_("Footnote arc in extended link %(linkrole)s from %(xlinkLabelFrom)s to %(xlinkLabelTo)s \"from\" is not a loc"),
modelObject=arcElt,
linkrole=modelLink.role, xlinkLabelFrom=fromLabel, xlinkLabelTo=toLabel)
if toLabel not in resourceLabels or resourceLabels[toLabel].qname != XbrlConst.qnLinkFootnote:
if not((toLabel in resourceLabels and resourceLabels[toLabel].qname == XbrlConst.qnLinkFootnote) or
(toLabel in locLabels and locLabels[toLabel].dereference().qname == XbrlConst.qnLinkFootnote)):
self.modelXbrl.error("xbrl.4.11.1.3.1:factFootnoteArcTo",
_("Footnote arc in extended link %(linkrole)s from %(xlinkLabelFrom)s to %(xlinkLabelTo)s \"to\" is not a footnote resource"),
modelObject=arcElt,
Expand Down
2 changes: 1 addition & 1 deletion arelle/ValidateXbrlDTS.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def checkDTS(val, modelDocument, checkedModelDocuments):
"calculationLink":("{http://www.w3.org/2001/XMLSchema}element",),
"definitionLink":("{http://www.w3.org/2001/XMLSchema}element",),
"presentationLink":("{http://www.w3.org/2001/XMLSchema}element",),
"footnoteLink":("XBRL-item-or-tuple",) }[hrefEltKey]:
"footnoteLink":("XBRL-item-or-tuple","{http://www.xbrl.org/2003/linkbase}footnote") }[hrefEltKey]:
if tgtTag == "XBRL-item-or-tuple":
concept = val.modelXbrl.qnameConcepts.get(qname(hrefedElt))
acceptableTarget = isinstance(concept, ModelDtsObject.ModelConcept) and \
Expand Down

0 comments on commit 8d31353

Please sign in to comment.