def validate_admin(xml): """ Validate a document agains admin.rng. Parameters and exceptions are the same as in L{enkel.exml.validate.validate_inline}. """ rng_file = join(RNGDIR, "admin.rng") rng_doc = parse(rng_file) rng = RelaxNG(rng_doc) rng.assertValid(xml)
def validate_admin(xml): """ Validate a document agains admin.rng. Parameters and exceptions are the same as in L{enkel.exml.validate.validate_inline}. """ rng_file = join(RNGDIR, "admin.rng") rng_doc = parse(rng_file) rng = RelaxNG(rng_doc) rng.assertValid(xml)
def validate_post(xml): """ Validate a post. Validate a xml document against section.rng. Parameters and excetions are the same as L{enkel.exml.validate.validate_inline}. """ rng_doc = parse(rng_file) rng = RelaxNG(rng_doc) rng.assertValid(xml)
def validate3(fieldname, xml, offset): rng = RelaxNG(XML(""" <element name='b' xmlns='http://relaxng.org/ns/structure/1.0'> <text/> </element>""")) try: rng.assertValid(XML(xml)) except LxmlError, e: raise LxmlFieldValidationError(fieldname, xml, offset, e)
def validate_post(xml): """ Validate a post. Validate a xml document against section.rng. Parameters and excetions are the same as L{enkel.exml.validate.validate_inline}. """ rng_doc = parse(rng_file) rng = RelaxNG(rng_doc) rng.assertValid(xml)
def test_preprocess(self): posts = join(self.tmp, "posts") tags = join(self.tmp, "tags") preprocess(posts, tags, self.postsfolder) rng = RelaxNG(parse(join(SRNGDIR, "posts.rng"))) rng.assertValid(parse(posts)) res = open(posts, "rb").read() self.assertEquals(res.count("<post "), 3) rng = RelaxNG(parse(join(SRNGDIR, "tags.rng"))) rng.assertValid(parse(tags)) res = open(tags, "rb").read() self.assertEquals(res.count("<tag "), 3)
def test_preprocess(self): posts = join(self.tmp, "posts") tags = join(self.tmp, "tags") preprocess(posts, tags, self.postsfolder) rng = RelaxNG(parse(join(SRNGDIR, "posts.rng"))) rng.assertValid(parse(posts)) res = open(posts, "rb").read() self.assertEquals(res.count("<post "), 3) rng = RelaxNG(parse(join(SRNGDIR, "tags.rng"))) rng.assertValid(parse(tags)) res = open(tags, "rb").read() self.assertEquals(res.count("<tag "), 3)