Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
    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
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
 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
Ejemplo n.º 9
0
    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()
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
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$
            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 = groupEle.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 _getChildrenForGroup()

    def getElementAttributes(self, aElementName, bRequiredAttrOnly=False):
        u"""Returns list of attributes given element name.""" #$NON-NLS-1$
        rList = []
        ele = self._getElement(aElementName)
        if ele:
            rList.extend( self._getAttributesForElement(ele, bRequiredAttrOnly) )
        return rList
    # end getElementAttributes()

    def _getAttributesForElement(self, aElement, bRequiredAttrOnly=False):
        rList = []
        # top level attributes
        attList = aElement.selectNodes(u"descendant::xs:attribute") #$NON-NLS-1$
        for att in attList:
            if self._isSupportAttribute(att, bRequiredAttrOnly):
                rList.append(att.getAttribute(u"name"))#$NON-NLS-1$

        # groups
        attList = aElement.selectNodes(u"descendant::xs:attributeGroup") #$NON-NLS-1$
        for att in attList:
            rList.extend( self._getAttributesForGroup(att.getAttribute(u"ref"), bRequiredAttrOnly) ) #$NON-NLS-1$
        return rList
    # _getAttributesForElement()

    def _getAttributesForGroup(self, aAttrGroupName, bRequiredAttrOnly=False):
        rList = []
        attGroupEle = self._getAttributeGroup(aAttrGroupName)
        if attGroupEle:
            # top level attributes
            attList = attGroupEle.selectNodes(u"descendant::xs:attribute") #$NON-NLS-1$
            for att in attList:
                if self._isSupportAttribute(att, bRequiredAttrOnly):
                    rList.append(att.getAttribute(u"name")) #$NON-NLS-1$

            # groups
            attList = attGroupEle.selectNodes(u"descendant::xs:attributeGroup") #$NON-NLS-1$
            for att in attList:
                rList.extend( self._getAttributesForGroup(att.getAttribute(u"ref"), bRequiredAttrOnly) )    #$NON-NLS-1$
        return rList
    # end _getAttributesForGroup()

    def _isRequiredAttribute(self, aAttrElement):
        # Returns true if required.
        return aAttrElement.getAttribute(u"use").lower() == u"required"  #$NON-NLS-1$  #$NON-NLS-2$
    # end _isRequiredAttribute()

    def _isSupportAttribute(self, aAttrElement, bRequiredAttrOnly=False):
        # skip Script type attributes (onBlur, onFocus) for the Joey editor.
        if bRequiredAttrOnly and not self._isRequiredAttribute(aAttrElement):
            return False
        return aAttrElement.getAttribute(u"type").lower() != u"script"  #$NON-NLS-1$  #$NON-NLS-2$
        # FIXME (PJ) : also skip for Coords, shape,
    # end _isSupportAttribute()

    def _isSupportedAttrGroup(self, aAttrGroupName):
        # skip events group (mouse up, onClick etc) for the Joey editor.
        return  aAttrGroupName != u"events"  #$NON-NLS-1$
    # end _isSupportedAttrGroup()

    def _getElement(self, aElementName):
        # returns the element given name or None if not found.
        rVal = None
        if aElementName:
            aElementName = aElementName.strip().lower()
            if self.elementMap.has_key(aElementName):
                rVal = self.elementMap[aElementName]
        return rVal
    # end _getElement()

    def _getGroup(self, aGroupName):
        # returns the group element given name or None if not found.
        rVal = None
        if self.groupsMap.has_key(aGroupName):
            rVal = self.groupsMap[aGroupName]
        return rVal
    # end _getGroup()

    def _getAttributeGroup(self, aAttrGroupName):
        # returns the attribute group element given name or None if not found.
        rVal = None
        if aAttrGroupName and self._isSupportedAttrGroup(aAttrGroupName) and self.attributeGroupsMap.has_key(aAttrGroupName):
            rVal = self.attributeGroupsMap[aAttrGroupName]
        return rVal
    # end _getAttributeGroup()

    def _initMaps(self):
        u"""Initialized lookup maps.""" #$NON-NLS-1$
        self.elementMap = {}
        eleList = self.getDocument().selectNodes(u"xs:element") #$NON-NLS-1$
        for ele in eleList:
            self.elementMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.complexTypesMap = {}
        # Eg. Inline, Block, Flow, a.content, pre.content
        eleList = self.getDocument().selectNodes(u"xs:complexType") #$NON-NLS-1$
        for ele in eleList:
            self.complexTypesMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.simpleTypesMap = {}
        # Eg ContentType,ContentTypes, URI, UriList
        eleList = self.getDocument().selectNodes(u"xs:simpleType") #$NON-NLS-1$
        for ele in eleList:
            self.simpleTypesMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.groupsMap = {}
        # Eg. special.pre, special, fontstyle, phrase, heading, blocktext, block
        eleList = self.getDocument().selectNodes(u"xs:group") #$NON-NLS-1$
        for ele in eleList:
            self.groupsMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.attributeGroupsMap = {}
        # Eg. coreattrs,i18n, attrs, events
        eleList = self.getDocument().selectNodes(u"xs:attributeGroup") #$NON-NLS-1$
        for ele in eleList:
            self.attributeGroupsMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$
Ejemplo n.º 12
0
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$
            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 = groupEle.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 _getChildrenForGroup()

    def getElementAttributes(self, aElementName, bRequiredAttrOnly=False):
        u"""Returns list of attributes given element name."""  #$NON-NLS-1$
        rList = []
        ele = self._getElement(aElementName)
        if ele:
            rList.extend(self._getAttributesForElement(ele, bRequiredAttrOnly))
        return rList

    # end getElementAttributes()

    def _getAttributesForElement(self, aElement, bRequiredAttrOnly=False):
        rList = []
        # top level attributes
        attList = aElement.selectNodes(
            u"descendant::xs:attribute")  #$NON-NLS-1$
        for att in attList:
            if self._isSupportAttribute(att, bRequiredAttrOnly):
                rList.append(att.getAttribute(u"name"))  #$NON-NLS-1$

        # groups
        attList = aElement.selectNodes(
            u"descendant::xs:attributeGroup")  #$NON-NLS-1$
        for att in attList:
            rList.extend(
                self._getAttributesForGroup(att.getAttribute(u"ref"),
                                            bRequiredAttrOnly))  #$NON-NLS-1$
        return rList

    # _getAttributesForElement()

    def _getAttributesForGroup(self, aAttrGroupName, bRequiredAttrOnly=False):
        rList = []
        attGroupEle = self._getAttributeGroup(aAttrGroupName)
        if attGroupEle:
            # top level attributes
            attList = attGroupEle.selectNodes(
                u"descendant::xs:attribute")  #$NON-NLS-1$
            for att in attList:
                if self._isSupportAttribute(att, bRequiredAttrOnly):
                    rList.append(att.getAttribute(u"name"))  #$NON-NLS-1$

            # groups
            attList = attGroupEle.selectNodes(
                u"descendant::xs:attributeGroup")  #$NON-NLS-1$
            for att in attList:
                rList.extend(
                    self._getAttributesForGroup(
                        att.getAttribute(u"ref"),
                        bRequiredAttrOnly))  #$NON-NLS-1$
        return rList

    # end _getAttributesForGroup()

    def _isRequiredAttribute(self, aAttrElement):
        # Returns true if required.
        return aAttrElement.getAttribute(
            u"use").lower() == u"required"  #$NON-NLS-1$  #$NON-NLS-2$

    # end _isRequiredAttribute()

    def _isSupportAttribute(self, aAttrElement, bRequiredAttrOnly=False):
        # skip Script type attributes (onBlur, onFocus) for the Joey editor.
        if bRequiredAttrOnly and not self._isRequiredAttribute(aAttrElement):
            return False
        return aAttrElement.getAttribute(
            u"type").lower() != u"script"  #$NON-NLS-1$  #$NON-NLS-2$
        # FIXME (PJ) : also skip for Coords, shape,

    # end _isSupportAttribute()

    def _isSupportedAttrGroup(self, aAttrGroupName):
        # skip events group (mouse up, onClick etc) for the Joey editor.
        return aAttrGroupName != u"events"  #$NON-NLS-1$

    # end _isSupportedAttrGroup()

    def _getElement(self, aElementName):
        # returns the element given name or None if not found.
        rVal = None
        if aElementName:
            aElementName = aElementName.strip().lower()
            if self.elementMap.has_key(aElementName):
                rVal = self.elementMap[aElementName]
        return rVal

    # end _getElement()

    def _getGroup(self, aGroupName):
        # returns the group element given name or None if not found.
        rVal = None
        if self.groupsMap.has_key(aGroupName):
            rVal = self.groupsMap[aGroupName]
        return rVal

    # end _getGroup()

    def _getAttributeGroup(self, aAttrGroupName):
        # returns the attribute group element given name or None if not found.
        rVal = None
        if aAttrGroupName and self._isSupportedAttrGroup(
                aAttrGroupName) and self.attributeGroupsMap.has_key(
                    aAttrGroupName):
            rVal = self.attributeGroupsMap[aAttrGroupName]
        return rVal

    # end _getAttributeGroup()

    def _initMaps(self):
        u"""Initialized lookup maps."""  #$NON-NLS-1$
        self.elementMap = {}
        eleList = self.getDocument().selectNodes(u"xs:element")  #$NON-NLS-1$
        for ele in eleList:
            self.elementMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.complexTypesMap = {}
        # Eg. Inline, Block, Flow, a.content, pre.content
        eleList = self.getDocument().selectNodes(
            u"xs:complexType")  #$NON-NLS-1$
        for ele in eleList:
            self.complexTypesMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.simpleTypesMap = {}
        # Eg ContentType,ContentTypes, URI, UriList
        eleList = self.getDocument().selectNodes(
            u"xs:simpleType")  #$NON-NLS-1$
        for ele in eleList:
            self.simpleTypesMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.groupsMap = {}
        # Eg. special.pre, special, fontstyle, phrase, heading, blocktext, block
        eleList = self.getDocument().selectNodes(u"xs:group")  #$NON-NLS-1$
        for ele in eleList:
            self.groupsMap[ele.getAttribute(u"name")] = ele  #$NON-NLS-1$

        self.attributeGroupsMap = {}
        # Eg. coreattrs,i18n, attrs, events
        eleList = self.getDocument().selectNodes(
            u"xs:attributeGroup")  #$NON-NLS-1$
        for ele in eleList:
            self.attributeGroupsMap[ele.getAttribute(
                u"name")] = ele  #$NON-NLS-1$