Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. ///////////////////////////////////////////////////////////
  2. // //
  3. // SSR Schema validation code //
  4. // usage cscript ValidateSchema.js <xsd file> <xml file> //
  5. // Author: Vishnu Patankar //
  6. // //
  7. ///////////////////////////////////////////////////////////
  8. var xsdfile = WScript.Arguments(0);
  9. var xmlfile = WScript.Arguments(1);
  10. var xml = new ActiveXObject("MSXML2.DOMDocument.4.0");
  11. var xsd = new ActiveXObject("MSXML2.DOMDocument.4.0");
  12. var schemas = new ActiveXObject("MSXML2.XMLSchemaCache.4.0");
  13. xml.async = false;
  14. xsd.async = false;
  15. function ValidateDataAgainstSchema()
  16. {
  17. if (xsd.load( xsdfile))
  18. {
  19. try
  20. {
  21. schemas.add( "", xsd);
  22. xml.schemas = schemas;
  23. }
  24. catch(e)
  25. {
  26. WScript.Echo( "Error processing XSD: \""+xsdfile+"\"\n"+e.description);
  27. return;
  28. }
  29. if (xml.load( xmlfile))
  30. {
  31. WScript.Echo( "Validation Successful: " + xmlfile + " conforms to " + xsdfile + "\n");
  32. }
  33. else
  34. {
  35. WScript.Echo( "Error Loading XML: \"" + xmlfile + "\"\n");
  36. WScript.Echo( xml.parseError.reason);
  37. }
  38. }
  39. else
  40. {
  41. WScript.Echo( "Error Loading XSD: \"" + xsdfile + "\"\n");
  42. WScript.Echo( xsd.parseError.reason);
  43. }
  44. } // function ValidateDataAgainstSchema()
  45. ValidateDataAgainstSchema();