Schematron

BTT Grammar Validator leverages schematron to validate BTT element reference, that is whether the defined BTT element is unique or not. BTT Validation Tool integrates schematron and provides a framework to interprete schematron validation result, so that the schematron validation result can be reported to Web Tools Platform (WTP) validation framework without any coding.

By this framework, you can plug your own schematron validation rule to BTT Validation Tool easily. What you need to do is to add your own rule in schematron format. The user-defined rule can be interpreted by the BTT Grammar Validator, and the errors will be detected and reported to the WTP validation framework.

Following is the standard schmatron validation rule for BTT deployment definition file (btt.sch):
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://www.ibm.com.cn/BTT612/schematron">
    <sch:pattern name="classpath and classtable">
        <sch:rule context="field">
	        <sch:assert test="not(@id) or not(@id='initializer') or not(@value!='com.ibm.btt.config.impl.GlobalSettings') or not(@value!='com.ibm.btt.base.TraceInitializer') or not(@value!='com.ibm.btt.channel.ChannelInitializer') or name(preceding-sibling::*[@id='extFile'])='field' or name(following-sibling::*[@id='extFile'])='field'">
	                class=com.ibm.btt.tools.validator.schematron.customrule.MessageAttributeValueHandler
	        		attribute=id
	        		message=The extFile is mandatory.
	        		type=2
	        </sch:assert>
        </sch:rule>
    </sch:pattern>
</sch:schema>
The schematron rules engine support the following rule format:
class=com.ibm.btt.tools.validator.schematron.customrule.MessageAttributeValueHandler
attribute=id
message=The extFile is mandatory
type=2
where:
  • Class is the implementation class of the validation rule. You can extend it to have your own validation implementation to support special validation.
  • Attribute is the attribute to be validated and it will be shown in the error message.
  • Message is the validation error message. It will be shown in the editor and problem view.
  • Type is the validation error type. 1 means that it is an error message; 2 means that it is a warning message, and 3 means that it is an information message.
If you want to extend BTT Grammar Validator, you can add your own rule to the related schematron rule file. For example, if you want to validate if there is a context named test_context, you can add your own rule as follows:
<sch:rule context="context">
    <sch:assert test="not(@id) or current()/@id != 'test_context'">
       class=com.ibm.btt.tools.validator.schematron.customrule.MessageAttributeValueHandler
attribute=id
message=Its id is not 'test_context'
type=2
    </sch:assert>
</sch:rule>
Then if there is a context in BTT global context xml file, and the value of its attribute id is "test_context", BTT Grammar Validator will detect this error and report the error to you.