Re: [xsl] How do I validate against a schema?

Subject: Re: [xsl] How do I validate against a schema?
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Fri, 10 Jan 2003 08:57:13 +0000
Hi Adrian,

I wrote a JScript batch file to do this back in April 2001 [1], to my surprise it seems to use the final XML Schema namespace.

---
C:\Desktop\xml\Demo>type msxsd.js
// 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("Houston, we have a problem: " + xmldoc.parseError.errorCode + " " + xmldoc.parseError.reason);
else
WScript.Echo("no problems!");
}


C:\xml\Demo>msxsd books.xml "" books.xsd
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

no problems!

C:\Documents and Settings\francis\Desktop\xml\Demo>
---

I'm sure there are better around - your error reporting looks more sophisticated than mine was, for a start...

Francis.

[1] http://www.schemavalid.com/utils/msxsd.zip




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread