def setDOMBindingNode(self, doc, node):
        """ sets data on term given by node """
        # set name(s)
        captionnodes=xml.getChildrenByTagName(node,'caption')
        if captionnodes:
            for langstringnode in xml.getChildrenByTagName(captionnodes[0],'langstring'):
                lang=langstringnode.getAttribute('language') or 'default'
                value=xml.getData(langstringnode)
                self.setTitle(value,lang=lang)

        descrnodes=xml.getChildrenByTagName(node,'description')
        if descrnodes:
            for langstringnode in xml.getChildrenByTagName(descrnodes[0],'langstring'):
                lang=langstringnode.getAttribute('language') or 'default'
                value=xml.getData(langstringnode)
                self.setDescription(value,lang=lang)

        # add mediadescriptors
        for medianode in xml.getChildrenByTagName(node,'mediaDescriptor'):
            loc = xml.getData(xml.getChildrenByTagName(medianode,'mediaLocator')[0])
            id="media.%s" % text.text.convertStringToId(loc)
            self.invokeFactory('VdexMediaDescriptor',id)
            self[id].setDOMBindingNode(doc,medianode)

        # add terms
        for termnode in xml.getChildrenByTagName(node,'term'):
            key = xml.getData(xml.getChildrenByTagName(termnode,'termIdentifier')[0])
            term=self.createTerm(key)
            term.setDOMBindingNode(doc,termnode)
    def importXMLBinding(self, data):
        """
        imports IMS VDEX compliant XML
        """

        # clean the house
        #self.manage_delObjects(self.objectIds())

        # build a minidom from data
        #data=data.decode('latin-1')
        doc=minidom.parseString(data)
        elroot = xml.getChildrenByTagName(doc,'vdex')[0]

        # set values from attributes
        self.setProfileType(elroot.getAttribute('profileType'))
        value=elroot.getAttribute('orderSignificant')
        if value is not None:
            self.setOrderSignificant(value)
        value=elroot.getAttribute('language')
        if value:
            self.setDefaultLanguage(value)
        value=elroot.getAttribute('isRegistered')
        if value:
            self.setRegistrationStatus(value)

        # set identifier
        idnodes=xml.getChildrenByTagName(elroot,'vocabIdentifier')
        if idnodes:
            self.setVocabularyIdentifier(xml.getData(idnodes[0]))

        # set name(s)
        namenodes=xml.getChildrenByTagName(elroot,'vocabName')
        if namenodes:
            for langstringnode in xml.getChildrenByTagName(namenodes[0],'langstring'):
                lang=langstringnode.getAttribute('language') or None
                value=xml.getData(langstringnode)
                self.setTitle(value,lang=lang)

        # update portal_catalog indexes with the full vocabulary information
        self.reindexObject()

        # add terms
        reindexqueue = []
        for termnode in xml.getChildrenByTagName(elroot,'term'):
            key = xml.getData(xml.getChildrenByTagName(termnode,'termIdentifier')[0])
            term=self.createTerm(key)
            term.setDOMBindingNode(doc,termnode)
            reindexqueue.append(term.getId())
        print "reindex new terms"
        for key in reindexqueue:            
            self[key].reindexObject()
        print "set savepoint"
        sp = transaction.savepoint(optimistic=True)