2015-10-14 30 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>

相關問題