Ejemplo n.º 1
0
 def testGet(self):
     self.doc = xmlext.parse('tests/a.xml')
     #self.doc = self.a.documentElement
     self.assertEqual(xmlext.getNodeText(self.doc, 'Number'), '868')
     self.assertEqual(xmlext.getNodeText(self.doc, 'OtherInfo/BirthDate'), '18071976')
     codeswith = xmlext.getAllNodes(self.doc, 'OtherInfo/CodesWith/Person')
     self.assertEqual(len(codeswith), 4)
     self.assertEqual(xmlext.getNodeText(codeswith[2]), 'Caglar')
Ejemplo n.º 2
0
 def testGet(self):
     self.doc = xmlext.parse('tests/a.xml')
     #self.doc = self.a.documentElement
     self.assertEqual(xmlext.getNodeText(self.doc, 'Number'), '868')
     self.assertEqual(xmlext.getNodeText(self.doc, 'OtherInfo/BirthDate'),
                      '18071976')
     codeswith = xmlext.getAllNodes(self.doc, 'OtherInfo/CodesWith/Person')
     self.assertEqual(len(codeswith), 5)
     self.assertEqual(xmlext.getNodeText(codeswith[1]), u'Çağlar')
Ejemplo n.º 3
0
 def decode(self, node, errs, where=""):
     # flags, tag name, instance attribute
     assert self.tag != ""
     nodes = xmlext.getAllNodes(node, self.tag)
     if not nodes:
         if self.req == mandatory:
             errs.append(where + ": " + _("At least one '%s' tag should have local text") % self.tag)
     else:
         for node in nodes:
             lang = xmlext.getNodeAttribute(node, "xml:lang")
             c = xmlext.getNodeText(node)
             if not c:
                 errs.append(where + ": " + _("'%s' language of tag '%s' is empty") % (lang, self.tag))
             # FIXME: check for dups and 'en'
             if not lang:
                 lang = "en"
             self[lang] = c
Ejemplo n.º 4
0
 def decode(self, node, errs, where=""):
     # flags, tag name, instance attribute
     assert self.tag != ''
     nodes = xmlext.getAllNodes(node, self.tag)
     if not nodes:
         if self.req == mandatory:
             errs.append(where + ': ' +
                         _("At least one '%s' tag should have local text") %
                         self.tag)
     else:
         for node in nodes:
             lang = xmlext.getNodeAttribute(node, 'xml:lang')
             c = xmlext.getNodeText(node)
             if not c:
                 errs.append(where + ': ' +
                             _("'%s' language of tag '%s' is empty") %
                             (lang, self.tag))
             # FIXME: check for dups and 'en'
             if not lang:
                 lang = 'en'
             self[lang] = c
Ejemplo n.º 5
0
 def readtext(node, blah):
     # node.normalize() # piksemel doesn't have this
     return xmlext.getNodeText(node)
Ejemplo n.º 6
0
 def readtext(node, tagpath):
     # print 'read tag', node, tagpath
     return xmlext.getNodeText(node, tagpath)
Ejemplo n.º 7
0
 def readtext(node, blah):
     #node.normalize() # piksemel doesn't have this
     return xmlext.getNodeText(node)
Ejemplo n.º 8
0
 def readtext(node, tagpath):
     #print 'read tag', node, tagpath
     return xmlext.getNodeText(node, tagpath)