Exemplo n.º 1
0
 def _test_cant_find(self):
     # This test is disabled since we need to determine what the
     # right thing to do is.  ;-(  The DOM Level 3 draft says
     # getDOMImplementation() should return null when there isn't a
     # match, but the existing Python API raises ImportError.
     self.my_features = []
     self.failUnless(domreg.getDOMImplementation(features="splat") is None)
     self.failUnless(
         domreg.getDOMImplementation(features="splat 1") is None)
Exemplo n.º 2
0
 def _test_cant_find(self):
     # This test is disabled since we need to determine what the
     # right thing to do is.  ;-(  The DOM Level 3 draft says
     # getDOMImplementation() should return null when there isn't a
     # match, but the existing Python API raises ImportError.
     self.my_features = []
     self.failUnless(domreg.getDOMImplementation(features="splat")
                     is None)
     self.failUnless(domreg.getDOMImplementation(features="splat 1")
                     is None)
Exemplo n.º 3
0
 def test_find_myself(self):
     self.my_features = [("splat", "1"), ("splat", "2"), ("splat", None)]
     self.failUnless(domreg.getDOMImplementation(features="splat")
                     is self.fake)
     self.failUnless(domreg.getDOMImplementation(features="splat 1")
                     is self.fake)
     self.failUnless(domreg.getDOMImplementation(features="splat 2")
                     is self.fake)
     self.failUnless(domreg.getDOMImplementation(features="splat 1 splat 2")
                     is self.fake)
     self.failUnless(domreg.getDOMImplementation(features="splat 2 splat 1")
                     is self.fake)
Exemplo n.º 4
0
 def test_find_myself(self):
     self.my_features = [("splat", "1"), ("splat", "2"), ("splat", None)]
     self.failUnless(
         domreg.getDOMImplementation(features="splat") is self.fake)
     self.failUnless(
         domreg.getDOMImplementation(features="splat 1") is self.fake)
     self.failUnless(
         domreg.getDOMImplementation(features="splat 2") is self.fake)
     self.failUnless(
         domreg.getDOMImplementation(
             features="splat 1 splat 2") is self.fake)
     self.failUnless(
         domreg.getDOMImplementation(
             features="splat 2 splat 1") is self.fake)
    def exportXMLBinding(self, sio=StringIO(), newl=VDEX_EXPORT_NEWL, addindent=VDEX_EXPORT_INDENT):
        """
        exports whole vocabulary as IMS VDEX compliant XML
        """

        # prepare minidom
        minidom =getDOMImplementation('minidom')
        doc=minidom.createDocument('', 'vdex', '')

        # build vdex base
        elroot = xml.getChildrenByTagName(doc,'vdex')[0]

        # attributes on base
        xml.setAttr(doc,elroot,'profileType',self.getProfileType())
        xml.setAttr(doc,elroot,'xmlns',
                    'http://www.imsglobal.org/xsd/imsvdex_v1p0')
        if self.getOrderSignificant():
            xml.setAttr(doc,elroot,'orderSignificant',self.getOrderSignificant())
        if self.getRegistrationStatus():
            xml.setAttr(doc,elroot,'isRegistered',self.getRegistrationStatus())
        if self.getDefaultLanguage():
            xml.setAttr(doc,elroot,'language',self.getDefaultLanguage())

        # node id
        xml.appendText(doc,elroot,'vocabIdentifier',self.getVocabularyIdentifier() or self.absolute_url())

        # node name with langstring
        elname=xml.appendNode(doc,elroot,'vocabName')
        for langstring in self.contentValues():
            if langstring.meta_type == "VdexLangstring":
                langnode=langstring.getDOMBindingNode(doc)
                elname.appendChild(langnode)

        # all term node
        for term in self.contentValues():
            if term.meta_type == "VdexTerm":
                node=term.getDOMBindingNode(doc)
                elroot.appendChild(node)

        # all realtionship nodes
        for rel in self.contentValues():
            if rel.meta_type == "VdexRelationship":
                node=rel.getDOMBindingNode(doc)
                elroot.appendChild(node)

        doc.writexml(sio, newl='\n', addindent='\t')
        return sio