TOP | BACK | FORW


2. DSDL(文書スキーマ定義言語)

(7) Schematronによる制約記述例



a) 制約
"blockstyle属性を指定するcharacter stringは, attlist.Styleに記述され ているstylelabel属性の値に一致すること" という制約は, 通常のスキーマでは記述できない。

... ... attlist.Page &= attlist.id, attribute pagestyle { text }, attlist.Common.Page element.TextBlock = element TextBlock { attlist.TextBlock, (element.P | element.CR)* } attlist.TextBlock &= attlist.id, attribute textstyle { text }, attribute blockstyle { text }, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attlist.Common.Text, attlist.Common.Block element.P = element P { attlist.P, DrawChar } ... ... element.BookStyle = element BookStyle { attlist.Style, element.SetDefault?, element.RegistFont*, element.BookSetting } attlist.Style &= attribute stylelabel { text }, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attlist.id element.SetDefault = element SetDefault { attlist.SetDefault, empty } attlist.Rubyoverhang &= attribute rubyoverhang { "auto" | "none" } attlist.SetDefault &= attribute rubyalign { text }, ... ...

b) 制約の記述
Schematronで書くと,次のようになる。

<?xml version="1.0" encoding="UTF-8"?> <sch:schema xmlns:sch="http://www.ascc.net/xml/schematron"> <sch:pattern name=""> <sch:rule context="TextBlock"> <sch:assert test="@blockstyle = //BookStyle/@stylelabel">No BookStyle elements specifying the name with the stylelabel attribute</sch:assert> </sch:rule> </sch:pattern> </sch:schema>

c) 参考

Schematronのtutorial: http://www.zvon.org/xxl/SchematronTutorial/General/toc.html RELAX NGスキーマのなかに上のスキーマを埋め込むことも可。 その方法は,次のページに示される。 http://www.xml.com/pub/a/2004/02/11/relaxtron.html


TOP | BACK | FORW