Exemple #1
0
 def set_doctype(self, doctype):
     dt = dtds.get_doctype(doctype)
     if dt:
         self.DOCTYPE = str(dt).encode("ascii")
         self.set_dtd(dtds.get_dtd_module(doctype))
         rootclass = getattr(self.dtd, identifier(dt.name))
         self.set_root(rootclass())
     else:
         raise ValidationError("Invalid doctype: %r" % (doctype, ))
Exemple #2
0
def new_document(doctype, encoding=DEFAULT_ENCODING):
    dtd = dtds.get_dtd_module(doctype)
    doc = POMDocument(dtd=dtd)
    doc.set_encoding(encoding)
    return doc