[xml] On validating a DOM with a schema, in Python



In Python, I need to validate a DOM tree using a W3C XML schema, but I cannot figure out how to do it. 
It seems that the C-function  xmlSchemaValidateDoc does the job but  I’m lost in the Python binding.
( My (naïve) trials were in the style:
  schemadoc = libxml2.parseFile("my-schema.wxs")
  schema = libxml2.Schema(schemadoc)
  ctxt = libxml2.SchemaValidCtxt(schema)
  #ctxt.schemaParse() ??
  doc = libxml2.parseFile("test.xml")
   res = doc.schemaValidateDoc(ctxt)
Is there anyone around that can show me the way? (I insist, that it is about validating a DOM already in memory)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]