%XML_Validate_XSD function


Function
The function executes the validation of XML document based on the grammar that is loaded from XSD document.
Declaration
BOOL %XML_Validate_XSD(
   INT in grammar,
   INT in doc
 )

Parameters
grammar Handle to XSD grammar.
doc Handle to XML document.

Return value
@TRUE - the function was done successfully
@FALSE - the function failed
Description
The function executes the validation of XML document based on the grammar that is loaded from XSD document. If the error occurred during validation, you may get the detailed information about it by calling the function %XML_GetLastErrorMessage.
Example
 INT _grammar, _doc
 BOOL _bFree
 
 _grammar := %XML_Load_XSD_Grammar(_FILE_XSD,"")
 IF _grammar\VLD = @FALSE | _grammar = 0 THEN
 _sError := "%XSD definition cannot be loaded!"+%XML_GetLastErrorMessage()
 RETURN
  ENDIF 
 
 _doc := %XML_OpenDocument(_FILE_XML,@FALSE,"",@FALSE) 
 IF _doc\VLD = @FALSE | _doc = 0 THEN
 _sError := "%XML Document cannot be opened! "+%XML_GetLastErrorMessage()
  _bFree := %XML_FreeGrammar(_grammar)
 RETURN
 ENDIF
 
 BOOL _bIsValid
 _bIsValid := %XML_Validate_XSD(_grammar,_doc)
 _bFree := %XML_FreeGrammar(_grammar)
 _bFree := %XML_FreeDocument(_doc) 
 IF _bIsValid\VLD = @FALSE | _bIsValid = @FALSE THEN
 _sError := "%XML_Validate_XSD doesn't work correctly!"+%XML_GetLastErrorMessage()
 RETURN 
  ENDIF 

Napíšte komentár