You have field elements or
attributes in your schema for which you want to restrict the valid
content beyond data type, enumerations, length, and minimum and maximum
You can use the Pattern
property of a field element or attribute to place a collection of
regular expressions. Regular expressions are used to do pattern matching
against the inbound data for the node. If the inbound data adheres to
the pattern(s) defined for a node, then the input instance document will
pass XML validation. If the inbound data for the node does not match
the pattern(s), then the input instance document will fail XML
validation. From within the BizTalk Editor, follow these steps to add a
regular expression to a field element or an attribute:
Select the field element or attribute node to which you wish to add restriction patterns.
Right-click and select Properties.
Set the Derived By property to Restriction. This will enable the Restriction properties within the Properties window.
Select the ellipsis next to the Pattern property to launch the Pattern Editor dialog box, as shown in Figure 1.
Figure 1. Pattern Editor dialog box
one to many valid regular expressions, and then click OK. The BizTalk
Editor will add these restriction patterns to the schema definition.
regular expressions are similar to those in other programming languages
that allow for pattern matching, there are some differences. Refer to
the W3C specification for the specifics of the regular expression syntax
3. How It Works
More restrictive validation
of the input data may be of value for numerous types of data, such as
phone numbers, IP addresses, and Social Security numbers. In these
cases, you can use regular expressions to restrict the type of data that
will be considered valid.
Once you have created a
schema that has nodes with pattern value restrictions, you can use the
Generate Instance and Validate Instance capabilities of the BizTalk
Editor to test your patterns.
If you have
pattern restrictions for a node(s) in your schema, the Generate Instance
option will not create an instance document with valid data for those
nodes. You will need to edit the instance document created. However, the
Validate Instance option will validate the schema, including
At runtime, neither
the PassThruReceive nor the XMLReceive pipeline will complete a strict
validation of the inbound document against the schema including the
pattern matching. To complete a thorough validation of an inbound
document, you must create a validation pipeline and add the document
schema to the Document Schema property of the XML validator. If the document fails schema validation in the pipeline, the instance will terminate.
In practice, it may be
more beneficial to handle the strict validation of data more gracefully
than terminating the instance when the validation fails. This is
especially true if the document is coming from an outside source or from
a system that is outside your control. However, restriction patterns
can be used to safeguard downstream systems and processes from bad data.