3.2. 基本的な XML ルールの作成
本セクションでは、MTA XML ルールを作成する方法を説明します。これは、すでに MTA がインストールされていることを前提としています。インストール手順は、MTA の『CLI ガイド』を参照してください。
3.2.1. 基本的な XML ルールテンプレートの作成
MTA XML ルールは 条件 と アクション で構成され、以下のルールパターンを使用します。
when(condition) perform(action) otherwise(action)
when(condition)
perform(action)
otherwise(action)
以下の内容で、XML ルールの基本的な構文であるファイルを作成します。
重要
MTA XML ルールファイルは .windup.xml
または .rhamt.xml
エクステンションを使用する必要があります。使用しないと、ルールは評価されません。
<?xml version="1.0"?> <ruleset id="unique-ruleset-id" xmlns="http://windup.jboss.org/schema/jboss-ruleset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> <metadata> <!-- Metadata about the rule including a description, source technology, target technology, and any add-on dependencies --> </metadata> <rules> <rule id="unique-ruleset-id-01000"> <when> <!-- Test a condition... --> </when> <perform> <!-- Perform this action when condition is satisfied --> </perform> <otherwise> <!-- Perform this action when condition is not satisfied --> </otherwise> </rule> <rules> </ruleset>
<?xml version="1.0"?>
<ruleset id="unique-ruleset-id"
xmlns="http://windup.jboss.org/schema/jboss-ruleset"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<!-- Metadata about the rule including a description,
source technology, target technology, and any
add-on dependencies -->
</metadata>
<rules>
<rule id="unique-ruleset-id-01000">
<when>
<!-- Test a condition... -->
</when>
<perform>
<!-- Perform this action when condition is satisfied -->
</perform>
<otherwise>
<!-- Perform this action when condition is not satisfied -->
</otherwise>
</rule>
<rules>
</ruleset>