当前位置: 首页>>代码示例>>Python>>正文


Python XmlValidate.validate方法代码示例

本文整理汇总了Python中arelle.XmlValidate.validate方法的典型用法代码示例。如果您正苦于以下问题:Python XmlValidate.validate方法的具体用法?Python XmlValidate.validate怎么用?Python XmlValidate.validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arelle.XmlValidate的用法示例。


在下文中一共展示了XmlValidate.validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createFact

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
 def createFact(self, conceptQname, attributes=None, text=None, parent=None, afterSibling=None, beforeSibling=None):
     if parent is None: parent = self.modelDocument.xmlRootElement
     newFact = XmlUtil.addChild(parent, conceptQname, attributes=attributes, text=text,
                                afterSibling=afterSibling, beforeSibling=beforeSibling)
     self.modelDocument.factDiscover(newFact, parentElement=parent)
     XmlValidate.validate(self, newFact)
     return newFact    
开发者ID:Bourne-Law,项目名称:Arelle,代码行数:9,代码来源:ModelXbrl.py

示例2: sEqual

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def sEqual(dts1, elt1, elt2, equalMode=S_EQUAL, excludeIDs=NO_IDs_EXCLUDED, dts2=None, ns2ns1Tbl=None):
    if dts2 is None: dts2 = dts1
    if elt1.localName != elt2.localName:
        return False
    if ns2ns1Tbl and elt2.namespaceURI in ns2ns1Tbl:
        if elt1.namespaceURI != ns2ns1Tbl[elt2.namespaceURI]:
            return False
    elif elt1.namespaceURI != elt2.namespaceURI:
        return False
    if not hasattr(elt1,u"xValid"):
        XmlValidate.validate(dts1, elt1)
    if not hasattr(elt2,u"xValid"):
        XmlValidate.validate(dts2, elt2)
    children1 = childElements(elt1)
    children2 = childElements(elt2)
    if len(children1) != len(children2):
        return False
    if (not xEqual(elt1, elt2,
                   # must use stringValue for nested contents of mixed content 
                   # ... this is now in xValue for mixed content
                   # VALIDATE_BY_STRING_VALUE if len(children1) and elt1.xValid == VALID else
                   equalMode
                   ) or 
        attributeDict(dts1, elt1, (), equalMode, excludeIDs) != 
        attributeDict(dts2, elt2, (), equalMode, excludeIDs, ns2ns1Tbl)):
        return False
    excludeChildIDs = excludeIDs if excludeIDs != TOP_IDs_EXCLUDED else NO_IDs_EXCLUDED
    for i in xrange( len(children1) ):
        if not sEqual(dts1, children1[i], children2[i], equalMode, excludeChildIDs, dts2, ns2ns1Tbl):
            return False
    return True
开发者ID:sternshus,项目名称:not_arelle2.7,代码行数:33,代码来源:XbrlUtil.py

示例3: equalityHash

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def equalityHash(elt, equalMode=S_EQUAL, excludeIDs=NO_IDs_EXCLUDED):
    if isinstance(elt, ModelObject):
        try:
            if equalMode == S_EQUAL:
                return elt._hashSEqual
            else:
                return elt._hashXpathEqual
        except AttributeError:
            dts = elt.modelXbrl
            if not hasattr(elt,"xValid"):
                XmlValidate.validate(dts, elt)
            hashableValue = elt.sValue if equalMode == S_EQUAL else elt.xValue
            if isinstance(hashableValue,float) and math.isnan(hashableValue): 
                hashableValue = (hashableValue,elt)    # ensure this NaN only compares to itself and no other NaN
            _hash = hash((elt.elementQname,
                          hashableValue,
                          tuple(attributeDict(dts, elt, (), equalMode, excludeIDs, distinguishNaNs=True).items()),
                          tuple(equalityHash(child,equalMode,excludeIDs) for child in childElements(elt))
                          ))
            if equalMode == S_EQUAL:
                elt._hashSEqual = _hash
            else:
                elt._hashXpathEqual = _hash
            return _hash
    elif isinstance(elt, (tuple,list,set)):
        return hash( tuple(equalityHash(i) for i in elt) )
    else:
        return hash(None)
开发者ID:marado,项目名称:Arelle,代码行数:30,代码来源:XbrlUtil.py

示例4: sEqual

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def sEqual(dts1, elt1, elt2, equalMode=S_EQUAL, excludeIDs=NO_IDs_EXCLUDED, dts2=None, ns2ns1Tbl=None):
    if dts2 is None: dts2 = dts1
    if elt1.localName != elt2.localName:
        return False
    if ns2ns1Tbl and elt2.namespaceURI in ns2ns1Tbl:
        if elt1.namespaceURI != ns2ns1Tbl[elt2.namespaceURI]:
            return False
    elif elt1.namespaceURI != elt2.namespaceURI:
        return False
    if not hasattr(elt1,"xValid"):
        XmlValidate.validate(dts1, elt1)
    if not hasattr(elt2,"xValid"):
        XmlValidate.validate(dts2, elt2)
    if (not xEqual(elt1, elt2, equalMode) or 
        attributeDict(dts1, elt1, (), equalMode, excludeIDs) != 
        attributeDict(dts2, elt2, (), equalMode, excludeIDs, ns2ns1Tbl)):
        return False
    children1 = childElements(elt1)
    children2 = childElements(elt2)
    if len(children1) != len(children2):
        return False
    excludeChildIDs = excludeIDs if excludeIDs != TOP_IDs_EXCLUDED else NO_IDs_EXCLUDED
    for i in range( len(children1) ):
        if not sEqual(dts1, children1[i], children2[i], equalMode, excludeChildIDs, dts2, ns2ns1Tbl):
            return False
    return True
开发者ID:marado,项目名称:Arelle,代码行数:28,代码来源:XbrlUtil.py

示例5: createUnit

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
 def createUnit(self, multiplyBy, divideBy, afterSibling=None, beforeSibling=None):
     """Creates new unit, by measures, as in formula usage, if any
     
     :param multiplyBy: List of multiply-by measure QNames (or top level measures if no divideBy)
     :type multiplyBy: [QName]
     :param divideBy: List of multiply-by measure QNames (or empty list if no divideBy)
     :type divideBy: [QName]
     :param beforeSibling: lxml element in instance to insert new concept before
     :type beforeSibling: ModelObject
     :param afterSibling: lxml element in instance to insert new concept after
     :type afterSibling: ModelObject
     :returns: ModelUnit -- New unit object
     """
     xbrlElt = self.modelDocument.xmlRootElement
     if afterSibling == AUTO_LOCATE_ELEMENT:
         afterSibling = XmlUtil.lastChild(xbrlElt, XbrlConst.xbrli, ("schemaLocation", "roleType", "arcroleType", "context", "unit"))
     unitId = 'u-{0:02n}'.format( len(self.units) + 1)
     newUnitElt = XmlUtil.addChild(xbrlElt, XbrlConst.xbrli, "unit", attributes=("id", unitId),
                                   afterSibling=afterSibling, beforeSibling=beforeSibling)
     if len(divideBy) == 0:
         for multiply in multiplyBy:
             XmlUtil.addChild(newUnitElt, XbrlConst.xbrli, "measure", text=XmlUtil.addQnameValue(xbrlElt, multiply))
     else:
         divElt = XmlUtil.addChild(newUnitElt, XbrlConst.xbrli, "divide")
         numElt = XmlUtil.addChild(divElt, XbrlConst.xbrli, "unitNumerator")
         denElt = XmlUtil.addChild(divElt, XbrlConst.xbrli, "unitDenominator")
         for multiply in multiplyBy:
             XmlUtil.addChild(numElt, XbrlConst.xbrli, "measure", text=XmlUtil.addQnameValue(xbrlElt, multiply))
         for divide in divideBy:
             XmlUtil.addChild(denElt, XbrlConst.xbrli, "measure", text=XmlUtil.addQnameValue(xbrlElt, divide))
     self.modelDocument.unitDiscover(newUnitElt)
     XmlValidate.validate(self, newUnitElt)
     return newUnitElt
开发者ID:benrosemeyer-wf,项目名称:Arelle,代码行数:35,代码来源:ModelXbrl.py

示例6: attributeDict

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def attributeDict(modelXbrl, elt, exclusions=set(), equalMode=S_EQUAL, excludeIDs=NO_IDs_EXCLUDED, ns2ns1Tbl=None, keyByTag=False, distinguishNaNs=False):
    if not hasattr(elt,"xValid"):
        XmlValidate.validate(modelXbrl, elt)
    attrs = {}
    # TBD: replace with validated attributes
    for modelAttribute in elt.xAttributes.values():
        attrTag = modelAttribute.attrTag
        ns, sep, localName = attrTag.partition('}')
        attrNsURI = ns[1:] if sep else None
        if ns2ns1Tbl and attrNsURI in ns2ns1Tbl:
            attrNsURI = ns2ns1Tbl[attrNsURI]
        if (attrTag not in exclusions and 
            (attrNsURI is None or attrNsURI not in exclusions)):
            if keyByTag:
                qname = attrTag
            elif attrNsURI is not None:
                qname = QName(None, attrNsURI, localName)
            else:
                qname = QName(None, None, attrTag)
            try:
                if excludeIDs and modelAttribute.xValid == XmlValidate.VALID_ID:
                    continue
                value = modelAttribute.sValue if equalMode <= S_EQUAL2 else modelAttribute.xValue
                if distinguishNaNs and isinstance(value,float) and math.isnan(value):
                    value = (value,elt)
                attrs[qname] = value
            except KeyError:
                pass  # what should be done if attribute failed to have psvi value
    return attrs
开发者ID:marado,项目名称:Arelle,代码行数:31,代码来源:XbrlUtil.py

示例7: xEqual

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def xEqual(elt1, elt2, equalMode=S_EQUAL):
    if not hasattr(elt1,"xValid"):
        XmlValidate.validate(elt1.modelXbrl, elt1)
    if not hasattr(elt2,"xValid"):
        XmlValidate.validate(elt2.modelXbrl, elt2)
    if equalMode == S_EQUAL or (equalMode == S_EQUAL2 and not isinstance(elt1.sValue, QName)):
        return elt1.sValue == elt2.sValue
    else:
        return elt1.xValue == elt2.xValue
开发者ID:marado,项目名称:Arelle,代码行数:11,代码来源:XbrlUtil.py

示例8: usedOns

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
 def usedOns(self): 
     try:
         return self._usedOns
     except AttributeError:
         XmlValidate.validate(self.modelXbrl, self)
         self._usedOns = set(usedOn.xValue
                             for usedOn in self.iterdescendants("{http://www.xbrl.org/2003/linkbase}usedOn")
                             if isinstance(usedOn,ModelObject))
         return self._usedOns
开发者ID:marado,项目名称:Arelle,代码行数:11,代码来源:ModelDtsObject.py

示例9: xEqual

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def xEqual(elt1, elt2, equalMode=S_EQUAL):
    if not hasattr(elt1,u"xValid"):
        XmlValidate.validate(elt1.modelXbrl, elt1)
    if not hasattr(elt2,u"xValid"):
        XmlValidate.validate(elt2.modelXbrl, elt2)
    if equalMode == VALIDATE_BY_STRING_VALUE:
        return elt1.stringValue == elt2.stringValue
    elif equalMode == S_EQUAL or (equalMode == S_EQUAL2 and not isinstance(elt1.sValue, QName)):
        return elt1.sValue == elt2.sValue
    else:
        return elt1.xValue == elt2.xValue
开发者ID:sternshus,项目名称:not_arelle2.7,代码行数:13,代码来源:XbrlUtil.py

示例10: typedValue

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def typedValue(dts, element, attrQname=None):
    try:
        if attrQname:
            node = element.getAttributeNodeNS(attrQname.namespaceURI,attrQname.localName)
        else:
            node = element
        if node.xValid == XmlValidate.VALID:
            return node.xValue
    except AttributeError:
        if dts:
            XmlValidate.validate(dts, element, recurse=False, attrQname=attrQname)
            return typedValue(None, element, attrQname=attrQname)
        return None
开发者ID:8maki,项目名称:Arelle,代码行数:15,代码来源:XbrlUtil.py

示例11: typedValue

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def typedValue(dts, element, attrQname=None):
    try:
        if attrQname: # PSVI attribute value
            modelAttribute = element.xAttributes[attrQname.clarkNotation]
            if modelAttribute.xValid >= XmlValidate.VALID:
                return modelAttribute.xValue
        else: # PSVI element value (of text)
            if element.xValid >= XmlValidate.VALID:
                return element.xValue
    except (AttributeError, KeyError):
        if dts:
            XmlValidate.validate(dts, element, recurse=False, attrQname=attrQname)
            return typedValue(None, element, attrQname=attrQname)
    return None
开发者ID:marado,项目名称:Arelle,代码行数:16,代码来源:XbrlUtil.py

示例12: xfxc_element

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def  xfxc_element(xc, p, contextItem, args):
    if not 2 <= len(args) <= 4: raise XPathContext.FunctionNumArgs()
    qn = qnameArg(xc, p, args, 0, 'QName', emptyFallback=None)
    attrArg = args[1] if isinstance(args[1],(list,tuple)) else (args[1],)
    # attributes have to be pairs
    if attrArg:
        if len(attrArg) & 1 or any(not isinstance(attrArg[i], (QName, _STR_BASE))
                                   for i in range(0, len(attrArg),2)):
            raise XPathContext.FunctionArgType(1,"((xs:qname|xs:string),xs:anyAtomicValue)", errCode="xfxce:AttributesNotNameValuePairs")
        else:
            attrParam = [(attrArg[i],attrArg[i+1]) # need name-value pairs for XmlUtil function
                         for i in range(0, len(attrArg),2)]
    else:
        attrParam = None
         
    value = atomicArg(xc, p, args, 2, "xs:anyAtomicType", emptyFallback='') 
    if not value: # be sure '' is None so no text node is created
        value = None  
    if len(args) < 4:
        childElements = None
    else:
        childElements = xc.flattenSequence(args[3])
    
    # scratchpad instance document emulates fn:doc( ) to hold XML nodes
    scratchpadXmlDocUrl = "http://www.xbrl.org/2012/function/creation/xml_scratchpad.xml"
    if scratchpadXmlDocUrl in xc.modelXbrl.urlDocs:
        modelDocument = xc.modelXbrl.urlDocs[scratchpadXmlDocUrl]
    else:
        # create scratchpad xml document
        # this will get the fake instance document in the list of modelXbrl docs so that it is garbage collected
        from arelle import ModelDocument
        modelDocument = ModelDocument.create(xc.modelXbrl, 
                                             ModelDocument.Type.UnknownXML, 
                                             scratchpadXmlDocUrl,
                                             initialXml="<xfc:dummy xmlns:xfc='http://www.xbrl.org/2012/function/creation'/>")
        
    newElement = XmlUtil.addChild(modelDocument.xmlRootElement,
                                  qn,
                                  attributes=attrParam,
                                  text=value)
    if childElements:
        for element in childElements:
            if isinstance(element, etree.ElementBase):
                newElement.append(element)
                
    # node myst be validated for use in instance creation (typed dimension references)
    XmlValidate.validate(xc.modelXbrl, newElement)
                
    return newElement
开发者ID:Arelle,项目名称:Arelle,代码行数:51,代码来源:functionsXmlCreation.py

示例13: endElementNS

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
 def endElementNS(self, name, qname):
     thisQname = QName(None, *name)
     if self.qnameStack and self.qnameStack[0].elementQname == thisQname:
         elt = self.qnameStack.pop(0)
         if elt.namespaceURI == XbrlConst.xbrli:
             if elt.localName == "unit":
                 elt._measures = (sorted(elt._measures[0]), sorted(elt._measures[1]))
                 if elt.id in self.unitRefedFacts:
                     for fact in self.unitRefedFacts[elt.id]:
                         fact._unit = elt
                     del self.unitRefedFacts[elt.id]
             elif elt.localName == "context":
                 if elt.id in self.contextRefedFacts:
                     for fact in self.contextRefedFacts[elt.id]:
                         fact._context = elt
                     del self.contextRefedFacts[elt.id]
         self.currentNamespaceURI = None
         self.currentLocalName = None
         XmlValidate.validate(self.modelXbrl, elt, recurse=False)
         pass
开发者ID:Arelle,项目名称:Arelle,代码行数:22,代码来源:bigInstance.py

示例14: doc

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
def doc(xc, p, contextItem, args):
    if len(args) != 1: raise XPathContext.FunctionNumArgs()
    uri = stringArg(xc, args, 0, "xs:string", emptyFallback=None)
    if uri is None:
        return ()
    if xc.progHeader is None or xc.progHeader.element is None:
        raise XPathContext.XPathException(p, 'err:FODC0005', _('Function xf:doc no formula resource element for {0}').format(uri))
    if not UrlUtil.isValid(uri):
        raise XPathContext.XPathException(p, 'err:FODC0005', _('Function xf:doc $uri is not valid {0}').format(uri))
    normalizedUri = xc.modelXbrl.modelManager.cntlr.webCache.normalizeUrl(
                                uri, 
                                xc.progHeader.element.modelDocument.baseForElement(xc.progHeader.element))
    if normalizedUri in xc.modelXbrl.urlDocs:
        return xc.modelXbrl.urlDocs[normalizedUri].xmlDocument
    modelDocument = ModelDocument.load(xc.modelXbrl, normalizedUri)
    if modelDocument is None:
        raise XPathContext.XPathException(p, 'err:FODC0005', _('Function xf:doc $uri not successfully loaded {0}').format(uri))
    # assure that document is validated
    XmlValidate.validate(xc.modelXbrl, modelDocument.xmlRootElement)
    return modelDocument.xmlDocument
开发者ID:DaveInga,项目名称:Arelle,代码行数:22,代码来源:FunctionFn.py

示例15: contextDiscover

# 需要导入模块: from arelle import XmlValidate [as 别名]
# 或者: from arelle.XmlValidate import validate [as 别名]
 def contextDiscover(self, cntxElement):
     id = cntxElement.getAttribute("id")
     self.modelXbrl.contexts[id] = modelContext = ModelObject.createContext(self,cntxElement)
     for container in (("segment", modelContext.segDimValues, modelContext.segNonDimValues),
                       ("scenario", modelContext.scenDimValues, modelContext.scenNonDimValues)):
         containerName, containerDimValues, containerNonDimValues = container
         for containerElement in XmlUtil.descendants(cntxElement, XbrlConst.xbrli, containerName):
             for sElt in containerElement.childNodes:
                 if sElt.nodeType == 1:
                     if sElt.namespaceURI == XbrlConst.xbrldi and sElt.localName in ("explicitMember","typedMember"):
                         XmlValidate.validate(self.modelXbrl, sElt)
                         modelDimValue = ModelObject.createDimensionValue(self,sElt)
                         dimension = modelDimValue.dimension
                         if dimension and dimension not in containerDimValues:
                             containerDimValues[dimension] = modelDimValue
                         else:
                             modelContext.errorDimValues.append(modelDimValue)
                         modelContext.qnameDims[modelDimValue.dimensionQname] = modelDimValue # both seg and scen
                     else:
                         containerNonDimValues.append(sElt)
开发者ID:8maki,项目名称:Arelle,代码行数:22,代码来源:ModelDocument.py


注:本文中的arelle.XmlValidate.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。