[XML-SIG] Re: how to use XSV in python to validate an xml file against an xsd schema file

Henry S. Thompson ht@cogsci.ed.ac.uk
01 Apr 2003 10:06:44 +0100


"Nico Grubert" <nicogrubert@web.de> writes:


> Unfortunately, I do not know exactly what I have to do with the line
> " res[0].printme(sys.stdout) " you mentioned in your posting.

You seem to have missed my original posting, which that is a
correction to.  Here's the whole thing, corrected.


As its name suggests, runitAndShow does the output itself, but it goes
to stderr, so you may have just never seen it.

Also note the second argument is a list, so you need to say

>>> runitAndShow(xmlfile,[schemafile])

For your purposes, you want to do

"""
# validateTestXML.py

from XSV.driver import runit
import sys

xmlfile     = "myxmlfile.xml"
schemafile  = "myxsdfile.xsd"

res = runit( xmlfile, [schemafile] )

res[0].printme(sys.stdout)

"""

You can inspect res to see how your validation went.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                      Half-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
 [mail really from me _always_ has this .sig -- mail without it is forged spam]