Enabling XML validation for a Parse XML rule
Specify that the system is to validate incoming XML against an XML Schema Definition (XSD) file before the system attempts to parse the XML document.
When you enable XML validation for a Parse XML rule that calls other Parse XML rules, you do not need to enable validation on the called rules. By the time a called rule runs, the entire XML document is validated against the XSD.
When validation fails, the system adds page messages to the destination clipboard page containing the parsed output, so that page cannot be saved. Optionally, a Java exception can occur.
- In the navigation pane of Dev Studio, click Records.
- Expand the Integration-Mapping category, and then click Parse XML.
- Click the XML tab.
- In the XML schema section, in the Schema
URL field, enter the URL of an XSD document to validate against.The URL you enter must be accessible to the Pega Platform at run time. You can enter either an http: or file: url, as shown in the following example:
http://myserver/myproject/myschema.xsd
This field supports the Global Resource Settings syntax (=PageName.PropertyName). The default property name for this field is
pySchemaLocation
. For more information, see Fields that support the Global Resource Settings syntax. - In the XML validation section, in the Perform
Validation field, select when the system performs schema validation:
- To disable schema validation, select Never. This is the default option.
- To always perform schema validation when this parse rule is called, select Always.
- To perform schema validation only if the when condition rule specified in the When Rule field evaluates to true, select When.
- If the Perform Validation field is set to
When, in the When Rule field, specify the
when condition rule to use to determine whether to use schema validation before executing
the other aspects of this parse rule.Enter the second key to the rule—the When Name. To find the when condition rule at run time, the system uses the Applies To key part of this parse rule as the Applies To key part of the when condition rule.
- In the Schema Type, specify the type of validation: The following schema types are displayed if you selected Always or When in step 5. If you selected Never, this field is read-only.
- XSD
- DTD
- In the On Error field, specify how the Pega Platform reports validation errors:
- To report the error as a page message on the clipboard and continue processing, select Add Page Message.
- To report the error as a page message, write an exception into the log file, and stop processing, select Throw Exception.
- To update the contents of the tree control based on a new schema, click the Mapping tab, and then click Update.
- Optional: If the Substitution field on the Node
tab of the Mapping properties panel is set to
Type, in the Type Substitution section, set
the target Page Class:For more information, see Defining the mapping for a Parse XML rule.
- In the Type name field, enter the local name of the desired type name to be substituted.
- In the Namespace URI field, enter the namespace URI of the type name.
- In the Class name field, specify the class that will override the context class on the node where the substitution occurs.
- Optional: To add another type to be substituted, click Add.
- Optional: In the Element Substitution section, specify the following
information:Use this section when the Substitution field on the Node tab of the Mapping properties panel is set to Element to set the target page class.
- In the Element name field, enter the local name of the desired element to be substituted.
- In the Namespace URI field, enter the namespace URI of the element name.
- In the Class name field, specify the class that will override the context class on the node where the substitution occurs.
- Optional: To add another element to be substituted, click Add.
- Click Save.
Previous topic Defining pages and classes for a Parse XML rule Next topic Unit testing a Parse XML rule