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



Hi,

On Tue, 2005-10-25 at 17:14 +0200, Meunier, Jean-Luc wrote:
Hi,

 

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)
 
Thanks,
 
JL

I'm heading home, so just a short one: maybe the test suite
file "xstc/xstc.py" can be of some help; it uses schemaValidateDoc()
as well as schemaValidateFile() for stream-based validation.

Regards,

Kasimier





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