xml.validate(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

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

N/xml Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.xml

xml.Document

required

The xml.Document object to validate.

2015.2

options.xsdFilePathOrId

number | string

required

The file ID or path to the XSD in the File Cabinet to validate the XML document against.

2015.2

options.importFolderPathOrId

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

SSS_XML_DOES_NOT_CONFORM_TO_SCHEMA

The provided XML is invalid for the provided schema.

SSS_INVALID_XML_SCHEMA_OR_DEPENDENCY

Schema is an incorrectly structured XSD or the dependent schema cannot be found.

ILLEGAL_REQUEST_FOR_A_FILE_THAT_ISNT_DOWNLOADABLE

The logged in user doesn't have permission to access the file referenced by the options.xsdFilePathOrId property.

Syntax
Important:

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 

        

Related Topics

N/xml Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices