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


Python Document.setAttribute方法代码示例

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


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

示例1: XmlElement

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
 def XmlElement(tagName, text=None, **attrs):
     elem = Document().createElement(tagName)
     if text:
         textNode = Document().createTextNode(escape(text))
         elem.appendChild(textNode)
     if attrs:
         for attr, value in attrs.iteritems():
             elem.setAttribute(attr, escape(str(value)))
     return elem
开发者ID:edwardbadboy,项目名称:vdsm-ubuntu,代码行数:11,代码来源:libvirtCfg.py

示例2: xml

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
 def xml(self):
     """
         It returns xml.dom.minidom.Element representation of this SubGraph.
     """
     subXML = Document().createElement("SubGraph")
     subXML.setAttribute("id", "{0}".format(self.id))
     for mod in self.modules.values():
         subXML.appendChild(mod.xml())
     for con in self._connections:
         subXML.appendChild(con.xml())
     return subXML
开发者ID:ctu-osgeorel-proj,项目名称:dp-ruzicka-2012,代码行数:13,代码来源:core.py

示例3: domainElement

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
def domainElement(domainType):
    """
    Creates a <domain> element in a L{libvirt document<libvirtDocument>}
    when passed the hypervisor type.

    @param domainType: hypervisor type
    @type domainType: String

    @return: <domain> Element
    @rtype: DOM Element
    """
    domain = Document().createElement('domain')
    domain.setAttribute('type', domainType)
    return domain
开发者ID:Awingu,项目名称:open-ovf,代码行数:16,代码来源:OvfLibvirt.py

示例4: createLinkElement

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
 def createLinkElement(self):
     a = Document().createElement("a")
     text = ''
     http = self.link_content[0]
     if len(self.link_content) == 1:
         text =  Document().createTextNode(http)
         a.appendChild(text)
     else:
         in_count = 1
         if(self.link_content[1]=='|'):
             in_count = 2
         self.new_parser.tokenList = self.link_content[in_count:]
         self.new_parser.count = 0
         container = self.new_parser.parseToken("*container",'')
         nodes = container.childNodes
         for smallnode in nodes[:]:
             a.appendChild(smallnode)
     a.setAttribute("href", http)
     return a
开发者ID:kosttek,项目名称:wikitohtml,代码行数:21,代码来源:link.py

示例5: __findInheritanceRecursive

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
    def __findInheritanceRecursive(self, parentName):
        """Returns minidom structure - whole structure of ancestors of class specified by parentName"""

        rootLst = []
        # ask if anybody inherit from parentName, if so, create subentry
        for child in filter(lambda x: len(x.inheritance) > 0, self.classInstances):
            if parentName in child.inheritance:
                subEntry = Document().createElement("class")
                subEntry.setAttribute("name", child.name)
                subEntry.setAttribute("kind", child.kind)

                children = self.__findInheritanceRecursive(child.name)
                if len(children) != 0:
                    for ch in children:
                        subEntry.appendChild(ch)
                # else:
                #    subEntry.appendChild(Document().createTextNode(""))  # insert empty node, to prevent having self closing node

                rootLst.append(subEntry)

        return rootLst
开发者ID:kopecmartin,项目名称:Cpp-Classes-Analyzer,代码行数:23,代码来源:cls.py

示例6: toElement

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
    def toElement(self):
        """
        Create and return a DOM element for this object

        @return: DOM element based on the infomation stored within the object.
        @rtype: DOM element.
        """
        childF = Document().createElement('File')

        if self.file_id != None:
            childF.setAttribute("ovf:id", self.file_id)
        if self.size != None:
            childF.setAttribute("ovf:size", self.size)
        if self.href != None:
            childF.setAttribute("ovf:href", self.href)
        if self.compression != None:
            childF.setAttribute("ovf:compression", self.compression)
        if self.chunksize != None:
            childF.setAttribute("ovf:chunkSize", self.chunksize)

        return(childF)
开发者ID:Awingu,项目名称:open-ovf,代码行数:23,代码来源:OvfReferencedFile.py

示例7: save_xml

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
 def save_xml(self, xmlparent=None):
     typ = self.nodetype()
     if xmlparent is None:
         assert typ == Document.DOCUMENT_NODE
         xmlnode = Document()
         xmlnode.ownerDocument = xmlnode
     else:
         if typ == Document.ATTRIBUTE_NODE:
             xmlnode = xmlparent.ownerDocument.createAttribute(self.name())
         elif typ == Document.CDATA_SECTION_NODE:
             xmlnode = xmlparent.ownerDocument.createCDATASection()
         elif typ == Document.COMMENT_NODE:
             xmlnode = xmlparent.ownerDocument.createComment(self.attribute("data"))
         elif typ == Document.DOCUMENT_FRAGMENT_NODE:
             xmlnode = xmlparent.ownerDocument.createDocumentFragment()
         elif typ == Document.DOCUMENT_NODE:
             raise UserWarning("cannot create a DOCUMENT_NODE from there")
         elif typ == Document.DOCUMENT_TYPE_NODE:
             raise UserWarning("cannot create a DOCUMENT_TYPE_NODE from there")
         elif typ == Document.ELEMENT_NODE:
             xmlnode = xmlparent.ownerDocument.createElement(self.nodename())
             for key in self.attributes():
                 xmlnode.setAttribute(key, self.attribute(key))
         elif typ == Document.ENTITY_NODE:
             raise UserWarning("cannot create a ENTITY_NODE from there")
         elif typ == Document.ENTITY_REFERENCE_NODE:
             raise UserWarning("cannot create a ENTITY_REFERENCE_NODE from there")
         elif typ == Document.NOTATION_NODE:
             raise UserWarning("cannot create a NOTATION_NODE from there")
         elif typ == Document.PROCESSING_INSTRUCTION_NODE:
             xmlnode = xmlparent.ownerDocument.createProcessingInstruction()
         elif typ == Document.TEXT_NODE:
             xmlnode = xmlparent.ownerDocument.createTextNode(self.attribute("data"))
         else:
             raise UserWarning("problem")
             # xml tree save
         xmlparent.appendChild(xmlnode)
     for child in self.children():
         child.save_xml(xmlnode)
     return xmlnode
开发者ID:VirtualPlants,项目名称:openalea-components,代码行数:42,代码来源:xml_element.py

示例8: getConnectionsXML

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
	def getConnectionsXML(
		self, address=None, port=None, protocol=None, kind=None):
		
		r = [ ]

		for t in self.getConnections(address, port, protocol, kind):
			m = Document().createElement('connection')
			m.setAttribute('addr', t[0])
			m.setAttribute('port', str(t[1]))
			m.setAttribute('kind', t[2])
			m.setAttribute('protocol', t[3])

			r.append(m)

		return r
开发者ID:ComputerNetworks-UFRGS,项目名称:ManP2P-ng,代码行数:17,代码来源:peer.py

示例9: createAttNodes

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
    def createAttNodes(self, ancestor, attList, parentName):
        """Returns minidom structure of attributes"""

        global conflicts
        attNodes = []

        for att in attList:
            # print(self.existedAttC)
            if conflicts and self.conflictExists:
                if self.canExcludeMember(True, parentName, att.name):
                    continue
            if att.name not in self.existedAtt:
                self.existedAtt.append(att.name)
                aTag = Document().createElement("attribute")
                aTag.setAttribute("name", att.name)
                aTag.setAttribute("type", att.dataType)
                aTag.setAttribute("scope", att.scope)
                if ancestor:
                    fr = Document().createElement("from")
                    fr.setAttribute("name", parentName)
                    aTag.appendChild(fr)
                attNodes.append(aTag)

        return attNodes
开发者ID:kopecmartin,项目名称:Cpp-Classes-Analyzer,代码行数:26,代码来源:cls.py

示例10: printConflictMembers

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
    def printConflictMembers(self):
        """Returns minidom structure of conflict members"""

        conflictTag = Document().createElement("conflicts")

        for member in self.existedAttC[0::2]:
            memTag = Document().createElement("member")
            memTag.setAttribute("name", member)
            for className in self.existedAttC[self.existedAttC.index(member)+1]:
                clTag = Document().createElement("class")
                clTag.setAttribute("name", className)
                cl = self.findClass(className)

                CMember = cl.findAttribute(member)
                if CMember:  # it's attribute
                    att = Document().createElement("attribute")
                else:  # it's method
                    CMember = cl.findMethod(member)
                    att = Document().createElement("method")

                    if CMember.virtualPure is not None:
                        virtual = Document().createElement("virtual")
                        virtual.setAttribute("pure", CMember.virtualPure)
                        att.appendChild(virtual)

                    args = Document().createElement("arguments")
                    for i in range(len(CMember.argumentType)):
                        arg = Document().createElement("argument")
                        arg.setAttribute("name", CMember.argumentName[i])
                        arg.setAttribute("type", CMember.argumentType[i])
                        args.appendChild(arg)
                    att.appendChild(args)

                accessTag = Document().createElement(CMember.privacy)
                att.setAttribute("name", CMember.name)
                att.setAttribute("type", CMember.dataType)
                att.setAttribute("scope", CMember.scope)
                accessTag.appendChild(att)
                clTag.appendChild(accessTag)
                memTag.appendChild(clTag)

            conflictTag.appendChild(memTag)

        return conflictTag
开发者ID:kopecmartin,项目名称:Cpp-Classes-Analyzer,代码行数:46,代码来源:cls.py

示例11: createMethodNodes

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
    def createMethodNodes(self, ancestor, mList, classInst):
        """Returns minidom structure of methods"""

        mNodes = []

        for m in mList:
            if conflicts and self.conflictExists:
                if self.canExcludeMember(False, classInst.name, [m.name, m.argumentType]):
                    continue

            if [m.name, m.argumentType] not in self.existedM:
                self.existedM.append([m.name, m.argumentType])
                mTag = Document().createElement("method")
                mTag.setAttribute("name", m.name)
                mTag.setAttribute("type", m.dataType)
                mTag.setAttribute("scope", m.scope)

                if m.virtualPure is not None:
                    virtual = Document().createElement("virtual")
                    virtual.setAttribute("pure", m.virtualPure)
                    mTag.appendChild(virtual)

                if ancestor:
                    fr = Document().createElement("from")
                    fr.setAttribute("name", classInst.name)
                    mTag.appendChild(fr)

                argTag = Document().createElement("arguments")
                for i in range(len(m.argumentType)):
                    arg = Document().createElement("argument")
                    arg.setAttribute("name", m.argumentName[i])
                    arg.setAttribute("type", m.argumentType[i])
                    argTag.appendChild(arg)
                mTag.appendChild(argTag)

                mNodes.append(mTag)

        return mNodes
开发者ID:kopecmartin,项目名称:Cpp-Classes-Analyzer,代码行数:40,代码来源:cls.py

示例12: get_dom

# 需要导入模块: from xml.dom.minidom import Document [as 别名]
# 或者: from xml.dom.minidom.Document import setAttribute [as 别名]
def get_dom(element, **kwargs):
	""" Given a tag, returns a new dom element for that tag """
	from xml.dom.minidom import Document
	dom = Document().createElement(element)
	for key in kwargs: dom.setAttribute(key, kwargs[key])
	return dom 
开发者ID:conover,项目名称:zombie,代码行数:8,代码来源:html.py


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