Skip to content

ValidateDocument - cXMLDOMDocument

Sent to validate an XML Document

Type: Function
Return Data Type: Handle

Syntax

Function ValidateDocument Returns Handle

Call Example

Get ValidateDocument to HandleVariable

Description

ValidateDocument is sent to validate an XML Document.

Sample

This sample shows handling of a single error.

// handling single error case
Get AddExternalSchemaFile of hoDoc "http://www.Sample.com/xml/schemas/VdfCustomerSample" "customer.xsd" to bOk
Get ValidateDocument of hoDoc to hoParseErrorObject
If hoParseErrorObject Begin        
   : // handle error        
   Send Destroy of hoParseErrorObject
End

Sample

This sample shows handling of multiple errors.

Set pbMultipleErrorMessages of hoDoc to True
Get AddExternalSchemaFile of hoDoc "http://www.Sample.com/xml/schemas/VdfCustomerSample" "customer.xsd" to bOk
Get ValidateDocument of hoDoc to hoParseErrorObject
If hoParseErrorObject Begin        
    Get piErrorCount of hoParseErrorObject to iCount        
    For i from 0 to (iCount-1)
        Get ErrorItemNode of hoParseErrorObject i to hoErrorItem
        Get psReason of hoErrorItem to sReason
        Showln sReason
        Get psErrorXPath of hoErrorItem to sXPath
        Showln sXPath
        Send Destroy of hoErrorItem
    Loop

    Send Destroy of hoParseErrorObject
End

Also note that Microsoft's MSXML, and therefore FleXML, disables the use of document type definitions (DTDs) for validation. This is done for security reasons. This can result in pbResolveExternals, AddExternalSchemaFile and AddExternalSchemaDocument failing. If you have a document that requires validation with a DTD, you may enable DTD validation as follows:

Set pbDomSecondLevelProperty of hoDoc "ProhibitDTD" to False

Note that "ProhibitDTD" must be cased as shown.

See Also

cXMLDomParseError

Return Value

If there are no validations, returns 0. If there are errors, a cXMLDOMParseError object is returned. This object can be used see what the errors are (see cXMLDomParseError). You must remember to destroy this object when you are done with it.