# Validating

The schema validating done during run time is different than the validate done when you click Validate in the Test View tab of the XQ file during design time. The Schema validating done on XML and non-XML typed data during run time can actually modify the resulting data while the validating during design time does not modify the resulting data but it does report if any required elements or attributes defined in the schema are not present.

This section provides the following topics:

- Validating During Design Time
- Schema Validating During Run Time

### Validating During Design Time

During design time, Validate in the Source Data and Result Data panes in the Test View tab of an XQ file will be active if the selected source parameter or resulting data is a typed global XML element. To learn more see XML Global Elements, Global Types, and Local Elements.

For example, if a typed global XML parameter is selected in the Source Data pane, Validate will be active as shown in the following figure.

Validate will not be active if the selected source parameter or resulting data is one of the following types:

- Typed Non-XML

Note: Untyped Non-XML (RawData) data cannot be used in transformations.

- XmlObject (untyped XML object)
- XmlObjectList (untyped XML object list)
- Java Types (both Java primitive types and Java classes)
- XML global type—To learn more see XML Global Elements, Global Types, and Local Elements.
- XML local element—To learn more see XML Global Elements, Global Types, and Local Elements.

For these types, Validate will not be active as shown in the following figure.

If you click Validate in either the Source Data and Result Data panes in the Test View tab of an XQ file, the displayed XML is checked against it schema and any errors are reported during design time. The validating done during design time in the Test View is not the same as the schema validating that occurs during run time. The validating during design time does not modify the resulting XML document but it does check if any required elements or attributes defined in the schema are not present.

### Schema Validating During Run Time

In the Selected Source Types pane of the Configure XQuery Transformation Method pane, if the Schema Validate Parameters check box is selected, during run time, the source parameters that support schema validation will be schema validated against their associated schema before the transformation is executed. The XML parameters will be schema validated against their XML Schema while the typed non-XML parameters will be validated against the schema in the MFL file. The Schema Validate Parameters check box will be ignored for the parameters that do not support schema validation.

Note: In the Selected Source Types pane of the Configure XQuery Transformation Method pane, the Schema Validate Parameters check box is not active if any of selected source parameters cannot be schema validated.

The following table shows which types will and will not be schema validated during run time.

Type | Schema Validated? | To Learn More See . . .
--- | --- | ---
XML Global Element | Yes | XML Global Elements, Global Types, and Local Elements
Typed Non-XML | Yes |
XML Global Type | No | XML Global Elements, Global Types, and Local Elements
XML Local Element | No | XML Global Elements, Global Types, and Local Elements
XmlObject (untyped XML object) | No |
XmlObjectList (untyped XML object list) | No |
Java Types (both Java primitive types and Java classes) | No |

In the Selected Source Types pane of the Configure XQuery Transformation Method pane, if you select the Schema Validate Parameters check box, the parameter attribute of the @dtf:schema-validate annotation will be set to true. To learn more see @dtf:schema-validate Annotation.

In the Selected Source Types pane of the Configure XQuery Transformation pane, if you select the Schema Validate Return check box and the target parameter is a type that can be schema validated, during run time the target parameter is schema validated against its schema type after the transformation is executed. To learn more see @dtf:schema-validate Annotation.

The Schema validating done on typed XML or non-XML data during run time can actually modify the resulting data. For XML data, if default attributes and elements are specified in the XML Schema and these attributes and elements do not have values in the source document, the resulting XML will have these defaults specified. To learn more about XML schema validating, see Occurrence Constraints.

If schema validating fails during run time, the com.bea.transform.TransformException exception is thrown. How the exception is handled depends on the node that invokes the transformation. If there is an exception path associated with node at the node level, group level or globally for the business process, the exception path is invoked. If there is no exception path associated with the node, the exception will force the business process to fail. To learn about exception paths in business processes, see Handling Exceptions.