Databases Reference
In-Depth Information
<cmn:creditCard>
<cmn:cardType>MasterCard</cmn:cardType>
<cmn:cardHolderName>JohnSmith</cmn:cardHolderName>
<cmn:cardNumber>4570126723982904</cmn:cardNumber>
<cmn:expiryMonth>10</cmn:expiryMonth>
<cmn:expiryYear>2010</cmn:expiryYear>
<cmn:securityNo>5285</cmn:securityNo>
</cmn:creditCard>
</ebm:updateCreditCard>
</soap:Body>
</soap:Envelope>
A Schematron that checks that the credit card type is MasterCard or Visa could be
written as the following code snippet:
<?xmlversion="1.0"encoding="UTF-8"?>
<
schema
xmlns="http://www.ascc.net/xml/schematron">
<nsuri="http://rubiconred.com/obay/ebm/UserAccount"prefix="ebm"/>
<nsuri="http://rubiconred.com/obay/xsd/cmn"prefix="cmn"/>
<
pattern
name="CheckCreditCardType">
<
rule
context="/ebm:updateCreditCard/cmn:creditCard">
<
assert
test="cmn:cardType='MasterCard'or
cmn:cardType='Visa'">
CreditCardmustbeMasterCardorVisa
</assert>
</rule>
</pattern>
</schema>
From this, we can see that a Schematron is made of four key components:
pattern
,
rule
,
assert
, and
ns
contained within the
schema
element. We'll examine these
elements one-by-one, starting with the inner most element and working outwards.
Assertions
The
assert
element, as its name suggests, is used to define the constraints to be
enforced within an XML document. In the previous Schematron, we have defined the
following
assert
element:
<assert
test="cmn:cardType = 'MasterCard' or cmn:cardType = 'Visa'"
>
CreditCardmustbeMasterCardorVisa
</assert>