Salesforce

XMLValidate (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

XMLValidate (Magic xpa 3.x)

Validates an XML document against its schema. The XML’s schema can be specified inside the XML document using one of the following:

  • The attribute xsi:noNamespaceSchemaLocation= or xsi:SchemaLocation=

  • An optional (2nd) parameter to the function.

Syntax:

XMLValidate (XML [,XSD schema Url])

Parameters:

XML – A BLOB variable (the XML content).

XSD schema Url – URL (http or local) of a schema file.
If the schema has a targetNamespace, the 2nd parameter (if specified) must have the target namespace prefixed before the schema location, separated by a space. For example:

XMLValidate (File2Blb ('my.xml'), 'MY_NS http://srvr/my.xsd') , the same as if the schemaLocation was specified in the XML document itself.

Spaces in the schema path must be escaped. For example:

XMLValidate (File2Blb ('my.xml'), 'MY_NS http://my%20srvr/my.xsd')

Returns:

Logical (‘TRUE’ – valid, ‘FALSE’ – invalid).

  • If no schema was specified, the XML file is considered valid as long as the schema location is specified in the XML file.

  • If only warnings were found, the file is considered valid.

Note:

During runtime, each XMLValidate call will clear all error(s) of a former XMLValidate call, before execution.

Exceptions:

This function is not supported for Rich Client tasks.

Examples:

Verify ‘Invalid’ XMLValidate(File2Blb(‘my.xml’),’http://srvr/my.xsd’)

XMLValidate (xml-content) – e.g. XMLValidate (A) – A is a BLOB
Validate using 'schemaLocation’ – if ‘schemaLocation’ is missing – returns ‘FALSE’

XMLValidate (xml-content, schema-url) – e.g. XMLValidate (A, ‘http://server/a.xsd’) Always validate using schema-url (i.e. ignore ‘schemaLocation’)

See also:

XMLValidationError

How Do I Validate an XML Document?

The Online and Rich Client Samples projects (program XM11 and RXM11)

Reference
Attachment 
Attachment