Skip to content

AddExternalSchemaDocument - cXMLDOMDocument

Adds a schema document object to the schema cache

Type: Function
Return Data Type: Boolean

Parameters

Parameter Type Description
sSchema String Schema name
hSchemaIntf Handle Schema handle

Syntax

Function AddExternalSchemaDocument String sSchema Handle hSchemaIntf Returns Boolean

Call Example

Get AddExternalSchemaDocument sSchema hSchemaIntf to BooleanVariable

Description

Adds a schema document object to the schema cache.

Sample

Get Create U_cXmlDomDocument to hoSchemaDoc
Set psDocumentName of hoSchemaDoc to "customer.xsd"
Get LoadXMLDocument of hoSchemaDoc to bLoadOk
If (bLoadOk) Begin
    Get AddExternalSchemaDocument of hoDoc "http://www.Sample.com/xml/schemas/VdfCustomerSample" hoSchemaDoc to bOk
End
Send Destroy of hoSchemaDoc

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.

Make sure you test the return value of AddExternalSchemaFile and AddExternalSchemaDocument. If it fails, schema validation will not work. This method can fail for a variety of reasons (cannot load document, cannot resolve externals, cannot use a DTD, etc.). If this fails, AddExternalSchemaDocument probably provides the most flexible way to track down the issues as it separates the loading of the XML schema document from the adding of the schema to the main XML document.

See Also

ValidateDocument | AddExternalSchemaFile

Return Value

Returns True if the schema is successfully added.