| ENGLISH | JAPANESE |
| << | リラックスのしかた/第一部: RELAX Core/STEP 5: 大きすぎるモジュールの分割 | >> |
include要素によって参照することができます.include要素は参照されたモジュールの本体によって置き換えられます.include要素の使用例を考えてみます.まず,インクルードされる側のモジュールをつぎに示します.
<module
moduleVersion="1.2"
relaxCoreVersion="1.0"
targetNamespace=""
xmlns="http://www.xml.gr.jp/xmlns/relaxCore">
<interface/>
<elementRule role="bar" type="emptyString"/>
<tag name="bar"/>
</module>
|
このモジュールには,barに関するelementRuleとtag要素があります.interface要素は空要素です.このモジュールはbar.rlxに格納されているものとします.
次に,このモジュールを参照して取り込む側のモジュールを示します.
<module
moduleVersion="1.2"
relaxCoreVersion="1.0"
targetNamespace=""
xmlns="http://www.xml.gr.jp/xmlns/relaxCore">
<interface>
<export label="foo"/>
</interface>
<elementRule role="foo">
<ref label="bar"/>
</elementRule>
<tag name="foo"/>
<include moduleLocation="bar.rlx" />
</module>
|
このモジュールには,fooに関するelementRuleとtagが記述されています.モジュールの最後にあるinclude要素は,moduleLocation属性でbar.rlxを指定しています.
include要素は,参照されているモジュールの本体(module要素の内容のうち,interface以降)によって置き換えられます.この例では,つぎのように置き換えられます.
<module
moduleVersion="1.2"
relaxCoreVersion="1.0"
targetNamespace=""
xmlns="http://www.xml.gr.jp/xmlns/relaxCore">
<interface>
<export label="foo"/>
</interface>
<elementRule role="foo">
<ref label="bar"/>
</elementRule>
<tag name="foo"/>
<elementRule role="bar" type="emptyString"/>
<tag name="bar"/>
</module>
|
interface要素は空でした.次のように,interface要素に子要素を追加してみます.
<module
moduleVersion="1.2"
relaxCoreVersion="1.0"
targetNamespace=""
xmlns="http://www.xml.gr.jp/xmlns/relaxCore">
<interface>
<export label="bar"/>
</interface>
<elementRule role="bar" type="emptyString"/>
<tag name="bar"/>
</module>
|
この場合には,インクルードされる側のモジュールにあるinterface要素の内容が,インクルードする側のモジュールのinterface要素に追加されます.この例では次のようになります.
<module
moduleVersion="1.2"
relaxCoreVersion="1.0"
targetNamespace=""
xmlns="http://www.xml.gr.jp/xmlns/relaxCore">
<interface>
<export label="foo"/>
<export label="bar"/>
</interface>
<elementRule role="foo">
<ref label="bar"/>
</elementRule>
<tag name="foo"/>
<elementRule role="bar" type="emptyString"/>
<tag name="bar"/>
</module>
|
| << | リラックスのしかた/第一部: RELAX Core/STEP 5: 大きすぎるモジュールの分割 | >> |