2015-10-14 31 views
0

说,我的标签“果”,它可以是“香蕉”和“苹果”而已,没有任何文字,就像这样:如何将文本节点限制为几个变体?

<fruit>banana</fruit> 
<fruit>apple</fruit> 
<fruit>potato</fruit> <!-- wrong! --> 

如果我设置<text/>,它将允许任何文本.. 如何为此做一个更严格的Relax NG条目?

回答

0

请参阅http://relaxng.org/tutorial-20011203.html#IDAVXYR。因此,而不是

<element name="fruit"> 
    <text/> 
</element> 

使用

<element name="fruit"> 
    <choice> 
    <value>banana</value> 
    <value>apple</value> 
    </choice> 
</element> 

对于RELAX NG紧凑语法现实生活中的例子,看到https://github.com/citation-style-language/schema/blob/262af55030bd3f5b389d1b327b2e725d83da34c8/csl-repository.rnc#L89

element cs:rights { 
    "This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License" 
} 

只验证<rights>This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>

相关问题