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


Python ZDom.setNamespaceMap方法代码示例

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


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

示例1: clone

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import setNamespaceMap [as 别名]
 def clone(self):
     u"""clone() -> ZXhtmlDocument()
     Returns copy based on cloning the underlying ZDom instance for this document.""" #$NON-NLS-1$
     newDom = ZDom()
     newDom.loadXML(self.dom.serialize())
     newDom.setNamespaceMap(XHTML_NSS_MAP)
     xhtmlDoc = ZXhtmlDocument(newDom)
     xhtmlDoc.docTypeString = self.docTypeString
     xhtmlDoc.mRootAbsPath = self.mRootAbsPath
     return xhtmlDoc
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:12,代码来源:xhtmldoc.py

示例2: _loadBundle

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import setNamespaceMap [as 别名]
    def _loadBundle(self, bundleFilename):
        # Load the file and read in all its string mappings.
        dom = ZDom()
        dom.load(bundleFilename)
        dom.setNamespaceMap(SB_NSS_MAP)

        nl = dom.selectNodes(u"/sb:string-bundle/sb:string") #$NON-NLS-1$
        for n in nl:
            name = n.getAttribute(u"name") #$NON-NLS-1$
            val = n.getText()
            val = val.replace(u"\\n", u"\n") #$NON-NLS-2$ #$NON-NLS-1$
            val = val.replace(u"\\t", u"\t") #$NON-NLS-2$ #$NON-NLS-1$
            self.bundleMap[name] = val
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:15,代码来源:i18n.py

示例3: _createDocument

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import setNamespaceMap [as 别名]
 def _createDocument(self, xhtmlString, throwOnError = False):
     u"""Creates and loads the given string into the zDom."""  #$NON-NLS-1$
     xhtmlString = xhtmlString.lstrip()
     if xhtmlString.startswith(u"<!DOCTYPE"): #$NON-NLS-1$
         xhtmlString = xhtmlString[xhtmlString.find(u">") + 1:] #$NON-NLS-1$
     try:
         dom = ZDom()
         dom.setNamespaceMap(XHTML_NSS_MAP)
         dom.loadXML(xhtmlString)
         return dom
     except:
         if throwOnError:
             raise
         return None
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:16,代码来源:xhtmlio.py

示例4: deserialize

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import setNamespaceMap [as 别名]
 def deserialize(self, path):
     u"""deserialize(string) -> ZSpellChecker""" #$NON-NLS-1$
     fpath = os.path.join(path, u"spellchecker.xml") #$NON-NLS-1$
     dom = ZDom()
     dom.load(fpath)
     dom.setNamespaceMap({ u"ns" : IZAppNamespaces.RAVEN_SPELLCHECKER_NAMESPACE }) #$NON-NLS-1$
     spellcheckerElem = dom.documentElement
     
     dictionaryLanguage = self._deserializeDictionaryLanguage(spellcheckerElem)
     provider = self._deserializeProvider(spellcheckerElem, dictionaryLanguage)
     personalWordList = self._deserializePersonalDictionary(spellcheckerElem)
     autoCorrections = self._deserializeAutoCorrections(spellcheckerElem)
     
     return ZSpellChecker(path, dictionaryLanguage, provider, personalWordList, autoCorrections)
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:16,代码来源:spellcheckerimpl.py

示例5: _loadMimeTypes

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import setNamespaceMap [as 别名]
 def _loadMimeTypes(self, applicationModel):
     rval = {}
     
     mimeTypeFile = applicationModel.getResourceRegistry().getResourcePath(u"mimetypes.xml") #$NON-NLS-1$
     mimeTypeDom = ZDom()
     mimeTypeDom.load(mimeTypeFile)
     mimeTypeDom.setNamespaceMap({ u"mt" : IZAppNamespaces.RAVEN_MIMETYPES_NAMESPACE }) #$NON-NLS-1$
     
     mimeTypeNodes = mimeTypeDom.selectNodes(u"/mt:mime-types/mt:mime-type") #$NON-NLS-1$
     for mimeTypeNode in mimeTypeNodes:
         type = mimeTypeNode.selectSingleNodeText(u"mt:type") #$NON-NLS-1$
         ext = mimeTypeNode.selectSingleNodeText(u"mt:extension") #$NON-NLS-1$
         rval[ext] = ZMimeType(type, ext)
         
     return rval
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:17,代码来源:mimetypesimpl.py

示例6: importPersonalDictionary

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import setNamespaceMap [as 别名]
    def importPersonalDictionary(self):
        joeyConfigDom = self._getJoeyUserConfigDom()
        if not joeyConfigDom:
            return
        try:
            node = joeyConfigDom.selectSingleNode(u"/joey/user-config/spell-check/language") #$NON-NLS-1$
            if not node:
                return
            spellcheckLang = getNoneString( node.getText())
            if not spellcheckLang:
                return

            # FIXME (EPW) we could support other languages...
            if not spellcheckLang == u"en_US": #$NON-NLS-1$
                return

            # 1) read all words from ZBW personal-dictionary.xml file
            # 2) create new spellchecker.xml DOM
            # 3) save new Raven spellchecker file to 'PROFILE\LANG\spellchecker.xml'

            joeyDictFile = os.path.join(self.pathToJoeyProfile, u"spelling/personal-dictionary.xml") #$NON-NLS-1$
            dom = ZDom()
            dom.load(joeyDictFile)
            dom.setNamespaceMap(ZBW_PERSONAL_DICTIONARY_NSS_MAP)
            wordNodeList = dom.selectNodes(u"/pd:personal-dictionary/pd:word") #$NON-NLS-1$
            
            newDom = ZDom()
            newDom.loadXML(ZBlogWriterDictionaryImporter.SPELLCHECK_TEMPLATE)
            newDom.setNamespaceMap(RAVEN_SPELLCHECK_NSS_MAP)
            personalDictElem = newDom.selectSingleNode(u"/spl:spellchecker/spl:personal-dictionary") #$NON-NLS-1$
            
            for wordNode in wordNodeList:
                word = wordNode.getText()
                newWordElem = newDom.createElement(u"word", IZBlogAppNamespaces.RAVEN_SPELLCHECKER_NAMESPACE) #$NON-NLS-1$
                newWordElem.setText(word)
                personalDictElem.appendChild(newWordElem)
            
            outputDir = os.path.join(self.pathToRavenProfile, u"spellcheck/en_US") #$NON-NLS-1$
            os.makedirs(outputDir)
            outputFile = os.path.join(outputDir, u"spellchecker.xml") #$NON-NLS-1$
            newDom.save(outputFile, True)
        except ZException, ze:
            # FIXME (EPW) need to report errors in some way
            ze.printStackTrace()
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:46,代码来源:zbwimporter.py

示例7: ZXhtmlSchema

# 需要导入模块: from zoundry.base.zdom.dom import ZDom [as 别名]
# 或者: from zoundry.base.zdom.dom.ZDom import setNamespaceMap [as 别名]
class ZXhtmlSchema(IZXhtmlSchema):

    XS_NSS_MAP = {
        u"xs" : u"http://www.w3.org/2001/XMLSchema" #$NON-NLS-1$ #$NON-NLS-2$
    }

    def __init__(self, xsdFile):
        self.xsdFile = xsdFile
        self.dom = None
        self.elementMap = {}
        self.complexTypesMap = {}
        self.simpleTypesMap = {}
        self.groupsMap = {}
        self.attributeGroupsMap = {}

        try:
            self.dom = ZDom()
            self.dom.load(self.xsdFile)
            self.dom.setNamespaceMap(ZXhtmlSchema.XS_NSS_MAP)
            self._initMaps()
        except:
            pass

    def getSchemaFile(self):
        u"""Returns the schema xsd filename.""" #$NON-NLS-1$
        return self.xsdFile
    # end getSchemaFile

    def getDocument(self):
        u"""Returns the schema xsd ZDom.""" #$NON-NLS-1$
        return self.dom
    # end getDocument()

    def getAllElementNames(self):
        u"""Returns list of element names.""" #$NON-NLS-1$
        return self.elementMap.keys()
    # end getAllElementNames()

    def isMixedType(self, aElementName):
        u"""Returns true if the element supports mixed typed (e.g. characters and elements).""" #$NON-NLS-1$
        rVal = False
        ele = self._getElement(aElementName)
        if ele:
            complexEle = ele.selectSingleNode(u"descendant::xs:complexType") #$NON-NLS-1$
            if complexEle:
                mixed = complexEle.getAttribute(u"mixed")#$NON-NLS-1$
                rVal = mixed is not None and mixed.lower() == u"true" #$NON-NLS-1$
        return rVal
    # end isMixedType()

    def getElementDocumentation(self, aElementName):
        u"""Returns documentation for element. """ #$NON-NLS-1$
        rVal = None
        ele = self._getElement(aElementName)
        if ele:
            dEle = ele.selectSingleNode(u"descendant::xs:documentation") #$NON-NLS-1$
            if dEle:
                rVal = dEle.getText()
        return rVal
    # end getElementDocumentation

    def getElementChildren(self, aParentElementName, bMixedTypeOnly=False):
        u"""Returns list of child element names given parent element name.""" #$NON-NLS-1$
        rList = []
        parentEle = self._getElement(aParentElementName)
        if parentEle:
            eleList = parentEle.selectNodes(u"descendant::xs:element") #$NON-NLS-1$
            for ele in eleList:
                eleName = ele.getAttribute(u"ref")  #$NON-NLS-1$
                if not bMixedTypeOnly or (bMixedTypeOnly and self.isMixedType(eleName)):
                    rList.append(eleName)
            # complex tytpe extensions
            extList = parentEle.selectNodes(u"descendant::xs:extension") #$NON-NLS-1$
            for ext in extList:
                rList.extend( self._getChildrenForComplexType(ext.getAttribute(u"base"), bMixedTypeOnly) ) #$NON-NLS-1$
        return rList
    # end getElementChildren()

    def _getChildrenForComplexType(self, aComplexTypeName, bMixedTypeOnly=False):
        u"""Returns list of child element names given complexType name.""" #$NON-NLS-1$
        rList = []
        if self.complexTypesMap.has_key(aComplexTypeName):
            complexEle = self.complexTypesMap[aComplexTypeName]
            eleList = complexEle.selectNodes(u"descendant::xs:element") #$NON-NLS-1$
            for ele in eleList:
                eleName = ele.getAttribute(u"ref")  #$NON-NLS-1$
                if not bMixedTypeOnly or (bMixedTypeOnly and self.isMixedType(eleName)):
                    rList.append(eleName)
            groupList = complexEle.selectNodes(u"descendant::xs:group") #$NON-NLS-1$
            for group in groupList:
                rList.extend( self._getChildrenForGroup(group.getAttribute(u"ref"), bMixedTypeOnly) )  #$NON-NLS-1$
        return rList
    # end _getChildrenForComplexType()

    def _getChildrenForGroup(self, aGroupName, bMixedTypeOnly=False):
        u"""Returns list of child element names given group name.""" #$NON-NLS-1$
        rList = []
        groupEle = self._getGroup(aGroupName)
        if groupEle:
            eleList = groupEle.selectNodes(u"descendant::xs:element") #$NON-NLS-1$
#.........这里部分代码省略.........
开发者ID:Tidosho,项目名称:zoundryraven,代码行数:103,代码来源:xhtmlvalidationimpl.py


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