def lookup(self, document, proxyElement):
        # check if proxyElement's namespace is not known
        ns, sep, ln = proxyElement.tag.partition("}")
        if sep:
            ns = ns[1:]
        else:
            ln = ns
            ns = None
        if (ns and 
            ns not in self.discoveryAttempts and 
            ns not in self.modelXbrl.namespaceDocs):
            # is schema loadable?  requires a schemaLocation
            from arelle import XmlUtil, ModelDocument
            relativeUrl = XmlUtil.schemaLocation(proxyElement, ns)
            self.discoveryAttempts.add(ns)
            if relativeUrl:
                doc = ModelDocument.loadSchemalocatedSchema(self.modelXbrl, proxyElement, relativeUrl, ns, self.baseUrl)

        modelObjectClass = self.modelXbrl.matchSubstitutionGroup(
            qnameNsLocalName(ns, ln),
            elementSubstitutionModelClass)
        
        if modelObjectClass is not None:
            return modelObjectClass
        else:
            xlinkType = proxyElement.get("{http://www.w3.org/1999/xlink}type")
            if xlinkType == "extended": return ModelLink
            elif xlinkType == "locator": return ModelLocator
            elif xlinkType == "resource": return ModelResource
            return ModelObject
Пример #2
0
    def lookup(self, document, proxyElement):
        # check if proxyElement's namespace is not known
        ns, sep, ln = proxyElement.tag.partition("}")
        if sep:
            ns = ns[1:]
        else:
            ln = ns
            ns = None
        if (ns and ns not in self.discoveryAttempts
                and ns not in self.modelXbrl.namespaceDocs):
            # is schema loadable?  requires a schemaLocation
            relativeUrl = XmlUtil.schemaLocation(proxyElement, ns)
            self.discoveryAttempts.add(ns)
            if relativeUrl:
                doc = ModelDocument.loadSchemalocatedSchema(
                    self.modelXbrl, proxyElement, relativeUrl, ns,
                    self.baseUrl)

        modelObjectClass = self.modelXbrl.matchSubstitutionGroup(
            qnameNsLocalName(ns, ln), elementSubstitutionModelClass)

        if modelObjectClass is not None:
            return modelObjectClass
        elif (self.streamingOrSkipDTS
              and ns not in (XbrlConst.xbrli, XbrlConst.link)):
            # self.makeelementParentModelObject is set in streamingExtensions.py and ModelXbrl.createFact
            ancestor = proxyElement.getparent() or getattr(
                self.modelXbrl, "makeelementParentModelObject", None)
            while ancestor is not None:
                tag = ancestor.tag  # not a modelObject yet, just parser prototype
                if tag.startswith("{http://www.xbrl.org/2003/instance}"
                                  ) or tag.startswith(
                                      "{http://www.xbrl.org/2003/linkbase}"):
                    if tag == "{http://www.xbrl.org/2003/instance}xbrl":
                        return ModelFact  # element not parented by context or footnoteLink
                    else:
                        break  # cannot be a fact
                ancestor = ancestor.getparent()

        xlinkType = proxyElement.get("{http://www.w3.org/1999/xlink}type")
        if xlinkType == "extended": return ModelLink
        elif xlinkType == "locator": return ModelLocator
        elif xlinkType == "resource": return ModelResource

        return ModelObject
Пример #3
0
    def lookup(self, document, proxyElement):
        # check if proxyElement's namespace is not known
        ns, sep, ln = proxyElement.tag.partition("}")
        if sep:
            ns = ns[1:]
        else:
            ln = ns
            ns = None
        if (ns and 
            ns not in self.discoveryAttempts and 
            ns not in self.modelXbrl.namespaceDocs):
            # is schema loadable?  requires a schemaLocation
            relativeUrl = XmlUtil.schemaLocation(proxyElement, ns)
            self.discoveryAttempts.add(ns)
            if relativeUrl:
                doc = ModelDocument.loadSchemalocatedSchema(self.modelXbrl, proxyElement, relativeUrl, ns, self.baseUrl)

        modelObjectClass = self.modelXbrl.matchSubstitutionGroup(
            qnameNsLocalName(ns, ln),
            elementSubstitutionModelClass)
        
        if modelObjectClass is not None:
            return modelObjectClass
        elif (self.streamingOrSkipDTS and 
              ns not in (XbrlConst.xbrli, XbrlConst.link)):
            # self.makeelementParentModelObject is set in streamingExtensions.py and ModelXbrl.createFact
            ancestor = proxyElement.getparent() or getattr(self.modelXbrl, "makeelementParentModelObject", None)
            while ancestor is not None:
                tag = ancestor.tag # not a modelObject yet, just parser prototype
                if tag.startswith("{http://www.xbrl.org/2003/instance}") or tag.startswith("{http://www.xbrl.org/2003/linkbase}"):
                    if tag == "{http://www.xbrl.org/2003/instance}xbrl":
                        return ModelFact # element not parented by context or footnoteLink
                    else:
                        break # cannot be a fact
                ancestor = ancestor.getparent()
                
        xlinkType = proxyElement.get("{http://www.w3.org/1999/xlink}type")
        if xlinkType == "extended": return ModelLink
        elif xlinkType == "locator": return ModelLocator
        elif xlinkType == "resource": return ModelResource
        
        return ModelObject
 def lookup(self, node_type, document, ns, ln):
     # node_type is "element", "comment", "PI", or "entity"
     if node_type == "element":
         if ns == XbrlConst.xsd:
             if self.type is None:
                 self.type = SCHEMA
             if ln == "element":
                 return ModelConcept
             elif ln == "attribute":
                 return ModelAttribute
             elif ln == "attributeGroup":
                 return ModelAttributeGroup
             elif ln == "complexType" or ln == "simpleType":
                 return ModelType
             elif ln == "group":
                 return ModelGroupDefinition
             elif ln == "sequence":
                 return ModelSequence
             elif ln == "choice" or ln == "all":
                 return ModelChoice
             elif ln == "all":
                 return ModelAll
             elif ln == "any":
                 return ModelAny
             elif ln == "anyAttribute":
                 return ModelAnyAttribute
             elif ln == "enumeration":
                 return ModelEnumeration
         elif ns == XbrlConst.link:
             if self.type is None:
                 self.type = LINKBASE
             if ln == "roleType" or ln == "arcroleType":
                 return ModelRoleType
         elif ns == "http://edgar/2009/conformance":
             # don't force loading of test schema
             if ln == "variation":
                 return ModelTestcaseVariation
             else:
                 return ModelObject
         elif ln == "testcase" and (
             ns is None or ns in ("http://edgar/2009/conformance",) or ns.startswith("http://xbrl.org/")):
             return ModelObject
         elif ln == "variation" and (
             ns is None or ns in ("http://edgar/2009/conformance",) or ns.startswith("http://xbrl.org/")):
             return ModelTestcaseVariation
         elif ln == "testGroup" and ns == "http://www.w3.org/XML/2004/xml-schema-test-suite/":
             return ModelTestcaseVariation
         elif ln == "test-case" and ns == "http://www.w3.org/2005/02/query-test-XQTSCatalog":
             return ModelTestcaseVariation
         elif ns == XbrlConst.ver:
             if self.type is None:
                 self.type = VERSIONINGREPORT
         elif ns == "http://dummy":
             return etree.ElementBase
         if self.type is None and ln == "rss":
             self.type = RSSFEED
         elif self.type == RSSFEED:
             if ln == "item":
                 return ModelRssItem
             else:
                 return ModelObject
             
         # match specific element types or substitution groups for types
         return self.modelXbrl.matchSubstitutionGroup(
                                     qnameNsLocalName(ns, ln),
                                     elementSubstitutionModelClass)
     elif node_type == "comment":
         from arelle.ModelObject import ModelComment
         return ModelComment
     elif node_type == "PI":
         return etree.PIBase
     elif node_type == "entity":
         return etree.EntityBase
Пример #5
0
    def lookup(self, node_type, document, ns, ln):
        # node_type is "element", "comment", "PI", or "entity"
        if node_type == "element":
            if ns == XbrlConst.xsd:
                if self.type is None:
                    self.type = SCHEMA
                if ln == "element":
                    return ModelConcept
                elif ln == "attribute":
                    return ModelAttribute
                elif ln == "attributeGroup":
                    return ModelAttributeGroup
                elif ln == "complexType" or ln == "simpleType":
                    return ModelType
                elif ln == "group":
                    return ModelGroupDefinition
                elif ln == "sequence":
                    return ModelSequence
                elif ln == "choice" or ln == "all":
                    return ModelChoice
                elif ln == "all":
                    return ModelAll
                elif ln == "any":
                    return ModelAny
                elif ln == "anyAttribute":
                    return ModelAnyAttribute
                elif ln == "enumeration":
                    return ModelEnumeration
            elif ns == XbrlConst.link:
                if self.type is None:
                    self.type = LINKBASE
                if ln == "roleType" or ln == "arcroleType":
                    return ModelRoleType
            elif ns == "http://edgar/2009/conformance":
                # don't force loading of test schema
                if ln == "variation":
                    return ModelTestcaseVariation
                else:
                    return ModelObject
            elif ln == "testcase" and (ns is None or ns
                                       in ("http://edgar/2009/conformance", )
                                       or ns.startswith("http://xbrl.org/")):
                return ModelObject
            elif ln == "variation" and (ns is None or ns
                                        in ("http://edgar/2009/conformance", )
                                        or ns.startswith("http://xbrl.org/")):
                return ModelTestcaseVariation
            elif ln == "testGroup" and ns == "http://www.w3.org/XML/2004/xml-schema-test-suite/":
                return ModelTestcaseVariation
            elif ln == "test-case" and ns == "http://www.w3.org/2005/02/query-test-XQTSCatalog":
                return ModelTestcaseVariation
            elif ns == XbrlConst.ver:
                if self.type is None:
                    self.type = VERSIONINGREPORT
            elif ns == "http://dummy":
                return etree.ElementBase
            if self.type is None and ln == "rss":
                self.type = RSSFEED
            elif self.type == RSSFEED:
                if ln == "item":
                    return ModelRssItem
                else:
                    return ModelObject

            # match specific element types or substitution groups for types
            return self.modelXbrl.matchSubstitutionGroup(
                qnameNsLocalName(ns, ln), elementSubstitutionModelClass)
        elif node_type == "comment":
            from arelle.ModelObject import ModelComment
            return ModelComment
        elif node_type == "PI":
            return etree.PIBase
        elif node_type == "entity":
            return etree.EntityBase