[Home] [By Thread] [By Date] [Recent Entries]

  • From: Francis Norton <francis@r...>
  • To: Marcinkovics Tamas <marci@c...>
  • Date: Mon, 23 Apr 2001 14:05:39 +0100

Just in case anyone wants to try msxml4 schema validation from the
command line, the following trivial script file might be helpful.

I wouldn't bother posting this but the doc and samples are still
excitingly beta... :)

Francis.



// This file is:  msxsd.js
// first parameter is an XML files to be read in;
// second parameter is the namespace;
// third parameter is the schema file

// validate parameters
if(WScript.Arguments.length != 3)
{
	WScript.Echo("msxsd takes three arguments - datafile, namespace, schema
- eg:");
	WScript.Echo('msxsd books.xml "" books.xsd');
}
else
{
	var cache = new ActiveXObject("Msxml2.XMLSchemaCache.4.0");
	cache.add(WScript.Arguments(1), WScript.Arguments(2));
	
	var xmldoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
	xmldoc.async = false;
	xmldoc.schemas = cache;
	xmldoc.load(WScript.Arguments(0));
	
	if(xmldoc.parseError.errorCode != 0)
		WScript.Echo("We have a problem: " + xmldoc.parseError.errorCode + " "
+ xmldoc.parseError.reason);
	else
		WScript.Echo("no problems!");
}

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member