>> English <<
|
česky
ZVON
>
Tutorials
>
Schematron Tutorial
Intro
/
Search
/
ZVON
>> Example 2 <<
|
Prev
|
Next
|
Contents
Description
Contents models can be open (it means that any other element can be also used) or closed (no other element can be used) .
Schema
<
schema
xmlns="
http://www.ascc.net/xml/schematron
" >
<
pattern
name
="
Open model
">
<
rule
context
="
AAA
">
<
assert
test
="
BBB
"> BBB element is not present</
assert
>
<
assert
test
="
CCC
"> CCC element is not present</
assert
>
</
rule
>
</
pattern
>
<
pattern
name
="
Closed model
">
<
rule
context
="
AAA
">
<
assert
test
="
BBB
"> BBB element is not present</
assert
>
<
assert
test
="
CCC
"> CCC element is not present</
assert
>
<
assert
test
="
count(BBB|CCC) = count (*)
">There is an extra element</
assert
>
</
rule
>
</
pattern
>
</
schema
>
Sources and outputs
Source (XML 1)
Output
<AAA>
<BBB/>
</AAA>
Pattern:
Open model
/AAA
: CCC element is not present
Pattern:
Closed model
/AAA
: CCC element is not present
Source (XML 2)
Output
<AAA>
<BBB/>
<DDD/>
</AAA>
Pattern:
Open model
/AAA
: CCC element is not present
Pattern:
Closed model
/AAA
: CCC element is not present
/AAA
: There is an extra element