嗨我有这样的XML:
<databaza>
<dvd>
<movie>
<number_of_character>2</number_of_character>
<character>
<character_id>1</character_id>
</character>
<character>
<character_id>2</character_id>
</character>
</movie>
<movie>
<number_of_character>4</number_of_character>
<character>
<character_id>1</character_id>
</character>
<character>
<character_id>2</character_id>
</character>
<character>
<character_id>3</character_id>
</character>
<character>
<character_id>4</character_id>
</character>
</movie>
</dvd>
</databaza>
和schematron代码:
<pattern>
<rule context="databaza/dvd/movie/character">
<assert test="character_id <= ../number_of_character">
Element "character_id" is grater than element "number_of_character".</assert>
</rule>
</pattern>
<pattern>
<rule context="databaza/dvd/movie/character">
<assert test="current()/character_id < following-sibling::*[1]/character_id">
Bad order. </assert>
</rule>
</pattern>
我遇到了没有其他兄弟的部分的问题。 你能帮助我吗 ?
我使用了这两种模式,因为我需要从1到最大的顺序<character_id>
(元素<number_of_character>
)所以如果你有更好的模式,说数字必须按这些顺序,请写对我来说。
答案 0 :(得分:0)
我建议您修改上一个assert
:
<assert test="(current()/character_id < following-sibling::*[1]/character_id)
or not(following-sibling::*)">
Bad order. </assert>
这样规则就是'#34;中立&#34;对于最后一个<character>
兄弟姐妹。