Altova StyleVision 2025 Enterprise Edition

The validity of the current document is checked using the following script:.

 

// check validity of current document.
// if validation fails, show validation result in alert box .
function BtnTest()
{
  // get top-level object of automation interface
  var objApp = objStyleVisionControl.Application;
 
  // get the active document
  var objDocument = objApp.ActiveDocument;
 
  if ( objDocument == null )
     alert( "no active document found" );
  else
  {
    // define as arrays to support their usage as return parameters
    var errorText = new Array(1);
    var errorPos = new Array(1);
    var badData = new Array(1);
 
    var valid = objDocument.IsValid(errorText, errorPos, badData);
 
    if (! valid)
     {
          // compose the error description
          var text = errorText;
 
          // access that XMLData object only if filled in
          if (badData[0] != null)
              text += "(" + badData[0].Name + "/" + badData[0].TextValue + ")";
 
 
           alert("Validation error[" + errorPos + "]: " + text);
     }
    else
        alert("Document is valid");
  }
}

© 2019-2025 Altova GmbH