Databases Reference
In-Depth Information
Using a relative context
As we have defined an absolute path name for the rule context , it can only be
applied to the updateCreditCard operation. Ideally, we would like to write a
Schematron that can be used to validate all occurrences of creditCard , regardless
of which operation it appears in.
To do this, we need to specify a rule context that will match any occurrence of
creditCard , regardless of where it appears in the XML payload. We can achieve this
by using a relative context, such as " //cmn:CreditCard ", as shown in the following
code snippet:
<rulecontext="//cmn:creditCard">
</rule>
The key here is the // , as this tells Schematron to match a pattern which may occur
anywhere within the XML instance.
Patterns
Rules are defined with a pattern element. Each pattern can hold a collection of one
or more associated rules. Pattern contains a single attribute name, which contains
free format text used to describe the rules contained within it.
In our valCreditCard.sch Schematron, we have defined the following pattern:
<patternname="CheckCreditCardType">
</pattern>
When processing an XML instance, Schematron will apply each pattern against the
XML instance in pattern order. When checking against a pattern, Schematron will
check the XML instance against each rule contained within the pattern in rule order.
Namespaces
Namespaces are declared using the ns element. This has two attributes; one is uri ,
which is used to define the namespace URI, and the other is prefix , which is used to
define the namespace prefix.
For example, in our credit card validation Schematron, we define the namespace
http://rubiconred.com/obay/xsd/cmn with the following:
<nsuri="http://rubiconred.com/obay/xsd/cmn"prefix="cmn"/>
 
Search WWH ::




Custom Search