[XML-SIG] how to use XSV in python to validate an xml file against an xsd schema file
Henry S. Thompson
22 Mar 2003 11:34:27 +0000
"Nico Grubert" <firstname.lastname@example.org> writes:
> i played around with XSV. I have installed it on win2000 and run the XSV file from the command line passing an xml file and and xsd schema file.
> how can i use XSV in python ?
> I tried:
> # validateTestXML.py
> from XSV.driver import runitAndShow
> xmlfile = "myxmlfile.xml"
> schemafile = "myxsdfile.xsd"
> res = runitAndShow( xmlfile, schemafile )
> print res
> but python does not print out anything. how can I print, if the
> validation brought errors or not ?
> has anybody ever used it directly in python ?
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
For your purposes, you want to do
from XSV.driver import runit
xmlfile = "myxmlfile.xml"
schemafile = "myxsdfile.xsd"
res = runit( xmlfile, [schemafile] )
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: email@example.com
[mail really from me _always_ has this .sig -- mail without it is forged spam]