#NEWLINE# def checkFilingDTS( val , modelDocument , visited ) : #NEWLINE# #INDENT# global targetNamespaceDatePattern , efmFilenamePattern , roleTypePattern , arcroleTypePattern , arcroleDefinitionPattern , namePattern , linkroleDefinitionBalanceIncomeSheet , namespacesConflictPattern #NEWLINE# if ( targetNamespaceDatePattern is None ) : #NEWLINE# #INDENT# targetNamespaceDatePattern = re . compile ( '/([12][0-9]{3})-([01][0-9])-([0-3][0-9])|/([12][0-9]{3})([01][0-9])([0-3][0-9])|' ) #NEWLINE# efmFilenamePattern = re . compile ( '^[a-z0-9][a-zA-Z0-9_\\.\\-]*(\\.xsd|\\.xml)$' ) #NEWLINE# roleTypePattern = re . compile ( '^.*/role/[^/\\s]+$' ) #NEWLINE# arcroleTypePattern = re . compile ( '^.*/arcrole/[^/\\s]+$' ) #NEWLINE# arcroleDefinitionPattern = re . compile ( '^.*[^\\\\s]+.*$' ) #NEWLINE# namePattern = re . compile ( '[][()*+?\\\\/^{}|@#%^=~`"\';:,<>&$£€]' ) #NEWLINE# linkroleDefinitionBalanceIncomeSheet = re . compile ( '[^-]+-\\s+Statement\\s+-\\s+.*(income|balance|financial\\W+position)' , re . IGNORECASE ) #NEWLINE# namespacesConflictPattern = re . compile ( 'http://(xbrl\\.us|fasb\\.org|xbrl\\.sec\\.gov)/(dei|us-types|us-roles|rr)/([0-9]{4}-[0-9]{2}-[0-9]{2})$' ) #NEWLINE# #UNINDENT# visited . append ( modelDocument ) #NEWLINE# for ( referencedDocument , modelDocumentReference ) in modelDocument . referencesDocument . items ( ) : #NEWLINE# #INDENT# if ( modelDocumentReference . referenceType == 'include' ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.0.18' , _ ( 'Taxonomy schema %(schema)s includes %(include)s, only import is allowed' ) , modelObject = modelDocumentReference . referringModelObject , schema = os . path . basename ( modelDocument . uri ) , include = os . path . basename ( referencedDocument . uri ) ) #NEWLINE# #UNINDENT# if ( referencedDocument not in visited ) : #NEWLINE# #INDENT# checkFilingDTS ( val , referencedDocument , visited ) #NEWLINE# #UNINDENT# #UNINDENT# if ( val . disclosureSystem . standardTaxonomiesDict is None ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if ( ( modelDocument . type == ModelDocument . Type . SCHEMA ) and ( modelDocument . targetNamespace not in val . disclosureSystem . baseTaxonomyNamespaces ) and modelDocument . uri . startswith ( val . modelXbrl . uriDir ) ) : #NEWLINE# #INDENT# definesLinkroles = False #NEWLINE# definesArcroles = False #NEWLINE# definesLinkParts = False #NEWLINE# definesAbstractItems = False #NEWLINE# definesNonabstractItems = False #NEWLINE# definesConcepts = False #NEWLINE# definesTuples = False #NEWLINE# definesPresentationTuples = False #NEWLINE# definesSpecificationTuples = False #NEWLINE# definesTypes = False #NEWLINE# definesEnumerations = False #NEWLINE# definesDimensions = False #NEWLINE# definesDomains = False #NEWLINE# definesHypercubes = False #NEWLINE# genrlSpeclRelSet = val . modelXbrl . relationshipSet ( XbrlConst . generalSpecial ) #NEWLINE# for modelConcept in modelDocument . xmlRootElement . iterdescendants ( tag = '{http://www.w3.org/2001/XMLSchema}element' ) : #NEWLINE# #INDENT# if isinstance ( modelConcept , ModelConcept ) : #NEWLINE# #INDENT# name = modelConcept . get ( 'name' ) #NEWLINE# if ( name is None ) : #NEWLINE# #INDENT# name = '' #NEWLINE# if ( modelConcept . get ( 'ref' ) is not None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# for c in val . modelXbrl . nameConcepts . get ( name , [ ] ) : #NEWLINE# #INDENT# if ( c . modelDocument != modelDocument ) : #NEWLINE# #INDENT# if ( not ( genrlSpeclRelSet . isRelated ( modelConcept , 'child' , c ) or genrlSpeclRelSet . isRelated ( c , 'child' , modelConcept ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.02' , _ ( 'Concept %(concept)s is also defined in standard taxonomy schema %(standardSchema)s without a general-special relationship' ) , modelObject = c , concept = modelConcept . qname , standardSchema = os . path . basename ( c . modelDocument . uri ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ' removed RH 2011-12-23 corresponding set up of table in ValidateFiling\n                if val.validateSBRNL and name in val.nameWordsTable:\n                    if not any( any( genrlSpeclRelSet.isRelated(c, "child", modelConcept)\n                                     for c in val.modelXbrl.nameConcepts.get(partialWordName, []))\n                                for partialWordName in val.nameWordsTable[name]):\n                        val.modelXbrl.error("SBR.NL.2.3.2.01",\n                            _("Concept %(specialName)s is appears to be missing a general-special relationship to %(generalNames)s"),\n                            modelObject=c, specialName=modelConcept.qname, generalNames=\', or to \'.join(val.nameWordsTable[name]))\n                ' #NEWLINE# if modelConcept . isTuple : #NEWLINE# #INDENT# if ( ( modelConcept . substitutionGroupQname . localName == 'presentationTuple' ) and modelConcept . substitutionGroupQname . namespaceURI . endswith ( '/basis/sbr/xbrl/xbrl-syntax-extension' ) ) : #NEWLINE# #INDENT# definesPresentationTuples = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( modelConcept . substitutionGroupQname . localName == 'specificationTuple' ) and modelConcept . substitutionGroupQname . namespaceURI . endswith ( '/basis/sbr/xbrl/xbrl-syntax-extension' ) ) : #NEWLINE# #INDENT# definesSpecificationTuples = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# definesTuples = True #NEWLINE# #UNINDENT# #UNINDENT# definesConcepts = True #NEWLINE# if modelConcept . isAbstract : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.03' , _ ( 'Concept %(concept)s is an abstract tuple' ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# if tupleCycle ( val , modelConcept ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.07' , _ ( 'Tuple %(concept)s has a tuple cycle' ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# if ( ( modelConcept . get ( 'nillable' ) != 'false' ) and modelConcept . isRoot ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.17' , _ ( "Tuple %(concept)s must have nillable='false'" ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if modelConcept . isItem : #NEWLINE# #INDENT# definesConcepts = True #NEWLINE# #UNINDENT# #UNINDENT# if ( modelConcept . abstract == 'true' ) : #NEWLINE# #INDENT# if modelConcept . isRoot : #NEWLINE# #INDENT# if ( modelConcept . get ( 'nillable' ) != 'false' ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.16' , _ ( "Abstract root concept %(concept)s must have nillable='false'" ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# if ( modelConcept . typeQname != XbrlConst . qnXbrliStringItemType ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.21' , _ ( "Abstract root concept %(concept)s must have type='xbrli:stringItemType'" ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# #UNINDENT# if modelConcept . balance : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.22' , _ ( 'Abstract concept %(concept)s must not have a balance attribute' ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# if modelConcept . isHypercubeItem : #NEWLINE# #INDENT# definesHypercubes = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if modelConcept . isDimensionItem : #NEWLINE# #INDENT# definesDimensions = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( modelConcept . substitutionGroupQname and ( modelConcept . substitutionGroupQname . localName in ( 'domainItem' , 'domainMemberItem' ) ) ) : #NEWLINE# #INDENT# definesDomains = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if modelConcept . isItem : #NEWLINE# #INDENT# definesAbstractItems = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if modelConcept . isItem : #NEWLINE# #INDENT# definesNonabstractItems = True #NEWLINE# if ( not ( modelConcept . label ( preferredLabel = XbrlConst . documentationLabel , fallbackToQname = False , lang = 'nl' ) or val . modelXbrl . relationshipSet ( XbrlConst . conceptReference ) . fromModelObject ( c ) or modelConcept . genLabel ( role = XbrlConst . genDocumentationLabel , lang = 'nl' ) or val . modelXbrl . relationshipSet ( XbrlConst . elementReference ) . fromModelObject ( c ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.28' , _ ( 'Concept %(concept)s must have a documentation label or reference' ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( modelConcept . balance and ( not modelConcept . instanceOfType ( XbrlConst . qnXbrliMonetaryItemType ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.2.24' , _ ( 'Non-monetary concept %(concept)s must not have a balance attribute' ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# if modelConcept . isLinkPart : #NEWLINE# #INDENT# definesLinkParts = True #NEWLINE# val . modelXbrl . error ( 'SBR.NL.2.2.5.01' , _ ( 'Link:part concept %(concept)s is not allowed' ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# if ( not modelConcept . genLabel ( fallbackToQname = False , lang = 'nl' ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.5.02' , _ ( "Link part definition %(concept)s must have a generic label in language 'nl'" ) , modelObject = modelConcept , concept = modelConcept . qname ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for e in modelDocument . xmlRootElement . iterdescendants ( tag = '{http://www.xbrl.org/2003/linkbase}roleType' ) : #NEWLINE# #INDENT# if isinstance ( e , ModelObject ) : #NEWLINE# #INDENT# roleURI = e . get ( 'roleURI' ) #NEWLINE# modelRoleTypes = val . modelXbrl . roleTypes . get ( roleURI ) #NEWLINE# if ( modelRoleTypes is not None ) : #NEWLINE# #INDENT# modelRoleType = modelRoleTypes [ 0 ] #NEWLINE# definition = modelRoleType . definitionNotStripped #NEWLINE# usedOns = modelRoleType . usedOns #NEWLINE# if ( ( usedOns & XbrlConst . standardExtLinkQnames ) or ( XbrlConst . qnGenLink in usedOns ) ) : #NEWLINE# #INDENT# definesLinkroles = True #NEWLINE# if ( not e . genLabel ( ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.3.03' , _ ( 'Link RoleType %(roleType)s missing a generic standard label' ) , modelObject = e , roleType = roleURI ) #NEWLINE# #UNINDENT# nlLabel = e . genLabel ( lang = 'nl' ) #NEWLINE# if ( definition != nlLabel ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.3.04' , _ ( 'Link RoleType %(roleType)s definition does not match NL standard generic label, \ndefinition: %(definition)s \nNL label: %(label)s' ) , modelObject = e , roleType = roleURI , definition = definition , label = nlLabel ) #NEWLINE# #UNINDENT# #UNINDENT# if ( definition and ( definition [ 0 ] . isspace ( ) or definition [ ( - 1 ) ] . isspace ( ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.3.07' , _ ( 'Link RoleType %(roleType)s definition has leading or trailing spaces: "%(definition)s"' ) , modelObject = e , roleType = roleURI , definition = definition ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for e in modelDocument . xmlRootElement . iterdescendants ( tag = '{http://www.xbrl.org/2003/linkbase}arcroleType' ) : #NEWLINE# #INDENT# if isinstance ( e , ModelObject ) : #NEWLINE# #INDENT# arcroleURI = e . get ( 'arcroleURI' ) #NEWLINE# definesArcroles = True #NEWLINE# val . modelXbrl . error ( 'SBR.NL.2.2.4.01' , _ ( 'Arcrole type definition is not allowed: %(arcroleURI)s' ) , modelObject = e , arcroleURI = arcroleURI ) #NEWLINE# #UNINDENT# #UNINDENT# for appinfoElt in modelDocument . xmlRootElement . iter ( tag = '{http://www.w3.org/2001/XMLSchema}appinfo' ) : #NEWLINE# #INDENT# for nonLinkElt in appinfoElt . iterdescendants ( ) : #NEWLINE# #INDENT# if ( isinstance ( nonLinkElt , ModelObject ) and ( nonLinkElt . namespaceURI != XbrlConst . link ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.11.05' , _ ( 'Appinfo contains disallowed non-link element %(element)s' ) , modelObject = nonLinkElt , element = nonLinkElt . qname ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for cplxTypeElt in modelDocument . xmlRootElement . iter ( tag = '{http://www.w3.org/2001/XMLSchema}complexType' ) : #NEWLINE# #INDENT# choiceElt = cplxTypeElt . find ( '{http://www.w3.org/2001/XMLSchema}choice' ) #NEWLINE# if ( choiceElt is not None ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.11.09' , _ ( 'ComplexType contains disallowed xs:choice element' ) , modelObject = choiceElt ) #NEWLINE# #UNINDENT# #UNINDENT# for cplxContentElt in modelDocument . xmlRootElement . iter ( tag = '{http://www.w3.org/2001/XMLSchema}complexContent' ) : #NEWLINE# #INDENT# if ( XmlUtil . descendantAttr ( cplxContentElt , 'http://www.w3.org/2001/XMLSchema' , ( 'extension' , 'restriction' ) , 'base' ) != 'sbr:placeholder' ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.11.10' , _ ( 'ComplexContent is disallowed' ) , modelObject = cplxContentElt ) #NEWLINE# #UNINDENT# #UNINDENT# for typeEltTag in ( '{http://www.w3.org/2001/XMLSchema}complexType' , '{http://www.w3.org/2001/XMLSchema}simpleType' ) : #NEWLINE# #INDENT# for typeElt in modelDocument . xmlRootElement . iter ( tag = typeEltTag ) : #NEWLINE# #INDENT# definesTypes = True #NEWLINE# name = typeElt . get ( 'name' ) #NEWLINE# if name : #NEWLINE# #INDENT# if ( ( not name [ 0 ] . islower ( ) ) or ( not name . isalnum ( ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.3.2.8.09' , _ ( 'Type name attribute must be lower camelcase: %(name)s.' ) , modelObject = typeElt , name = name ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for enumElt in modelDocument . xmlRootElement . iter ( tag = '{http://www.w3.org/2001/XMLSchema}enumeration' ) : #NEWLINE# #INDENT# definesEnumerations = True #NEWLINE# if any ( ( ( not valueElt . genLabel ( lang = 'nl' ) ) for valueElt in enumElt . iter ( tag = '{http://www.w3.org/2001/XMLSchema}value' ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.7.05' , _ ( 'Enumeration element has value(s) without generic label.' ) , modelObject = enumElt ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( ( ( ( ( ( ( ( ( ( ( ( definesLinkroles + usedOns ) + definesLinkParts ) + definesAbstractItems ) + definesNonabstractItems ) + definesTuples ) + definesPresentationTuples ) + definesSpecificationTuples ) + definesTypes ) + definesEnumerations ) + definesDimensions ) + definesDomains ) + definesHypercubes ) != 1 ) : #NEWLINE# #INDENT# schemaContents = [ ] #NEWLINE# if definesLinkroles : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'linkroles' ) ) #NEWLINE# #UNINDENT# if definesArcroles : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'arcroles' ) ) #NEWLINE# #UNINDENT# if definesLinkParts : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'link parts' ) ) #NEWLINE# #UNINDENT# if definesAbstractItems : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'abstract items' ) ) #NEWLINE# #UNINDENT# if definesNonabstractItems : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'nonabstract items' ) ) #NEWLINE# #UNINDENT# if definesTuples : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'tuples' ) ) #NEWLINE# #UNINDENT# if definesPresentationTuples : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'sbrPresentationTuples' ) ) #NEWLINE# #UNINDENT# if definesSpecificationTuples : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'sbrSpecificationTuples' ) ) #NEWLINE# #UNINDENT# if definesTypes : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'types' ) ) #NEWLINE# #UNINDENT# if definesEnumerations : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'enumerations' ) ) #NEWLINE# #UNINDENT# if definesDimensions : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'dimensions' ) ) #NEWLINE# #UNINDENT# if definesDomains : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'domains' ) ) #NEWLINE# #UNINDENT# if definesHypercubes : #NEWLINE# #INDENT# schemaContents . append ( _ ( 'hypercubes' ) ) #NEWLINE# #UNINDENT# if schemaContents : #NEWLINE# #INDENT# if ( not ( ( definesTuples or definesPresentationTuples or definesSpecificationTuples ) and ( not ( definesLinkroles or definesArcroles or definesLinkParts or definesAbstractItems or definesTypes or definesDimensions or definesDomains or definesHypercubes ) ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.1.01' , _ ( 'Taxonomy schema may only define one of these: %(contents)s' ) , modelObject = modelDocument , contents = ', ' . join ( schemaContents ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not any ( ( ( refDoc . inDTS and ( refDoc . targetNamespace not in val . disclosureSystem . baseTaxonomyNamespaces ) ) for refDoc in modelDocument . referencesDocument . keys ( ) ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.1.01' , _ ( 'Taxonomy schema must be a DTS entrypoint OR define linkroles OR arcroles OR link:parts OR context fragments OR abstract items OR tuples OR non-abstract elements OR types OR enumerations OR dimensions OR domains OR hypercubes' ) , modelObject = modelDocument ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( definesConcepts ^ any ( ( ( ( refDoc . type == ModelDocument . Type . LINKBASE ) and ( XmlUtil . descendant ( refDoc . xmlRootElement , XbrlConst . link , 'labelLink' ) is not None ) ) for refDoc in modelDocument . referencesDocument . keys ( ) ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.1.02' , _ ( 'A schema that defines concepts MUST have a linked 2.1 label linkbase' ) , modelObject = modelDocument ) #NEWLINE# #UNINDENT# if ( ( definesNonabstractItems or definesTuples ) and ( not any ( ( ( ( refDoc . type == ModelDocument . Type . LINKBASE ) and ( ( XmlUtil . descendant ( refDoc . xmlRootElement , XbrlConst . link , 'referenceLink' ) is not None ) or ( XmlUtil . descendant ( refDoc . xmlRootElement , XbrlConst . link , 'label' , '{http://www.w3.org/1999/xlink}role' , 'http://www.xbrl.org/2003/role/documentation' ) is not None ) ) ) for refDoc in modelDocument . referencesDocument . keys ( ) ) ) ) ) : #NEWLINE# #INDENT# val . modelXbrl . error ( 'SBR.NL.2.2.1.03' , _ ( 'A schema that defines non-abstract items MUST have a linked (2.1) reference linkbase AND/OR a label linkbase with @xlink:role=documentation' ) , modelObject = modelDocument ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( modelDocument . type == ModelDocument . Type . LINKBASE ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# visited . remove ( modelDocument )