xml.validate(options)
Method Description |
Validates an XML document against an XML Schema (XSD).
Important:
This method only validates XML Schema (XSD); validation of other XML schema languages is not supported. The XML document must be passed as an xml.Document object. The location of the source XML Document does not matter; the validation is performed with the Document object stored in memory. The XSD must be stored in the File Cabinet. |
Returns |
void |
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
Governance |
None |
Module |
|
Since |
2015.2 |
Parameters
The options parameter is a JavaScript object.
Parameter |
Type |
Required / Optional |
Description |
Since |
---|---|---|---|---|
|
required |
The xml.Document object to validate. |
2015.2 |
|
|
number | string |
required |
The file ID or path to the XSD in the File Cabinet to validate the XML document against. |
2015.2 |
|
number | string |
optional |
The folder ID or path to a folder in the File Cabinet containing additional XSD schemas which are imported by the parent XSD. |
2015.2 |
Errors
Error Code |
Thrown If |
---|---|
|
The provided XML is invalid for the provided schema. |
|
Schema is an incorrectly structured XSD or the dependent schema cannot be found. |
|
The logged in user doesn't have permission to access the file referenced by the |
Syntax
The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/xml Module Script Samples.
//Add additional code
...
xml.validate({
xml : xmlDocument,
xsdFilePathOrId : 'SuiteScripts/schema_parent.xsd',
importFolderPathOrId : 'SuiteScripts/'
});
...
//Add additional code