如何将文本节点限制为几个变体?
How limit the text node to a few variants?
说,我有标签 "fruit",它只能是 "banana" 和 "apple",不能是任何文本,像这样:
<fruit>banana</fruit>
<fruit>apple</fruit>
<fruit>potato</fruit> <!-- wrong! -->
如果我设置 <text/>
,它将允许任何文本...
我如何为此制定更严格的 Relax NG 条目?
参见 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 Compact 语法的真实示例,请参阅 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>
.
说,我有标签 "fruit",它只能是 "banana" 和 "apple",不能是任何文本,像这样:
<fruit>banana</fruit>
<fruit>apple</fruit>
<fruit>potato</fruit> <!-- wrong! -->
如果我设置 <text/>
,它将允许任何文本...
我如何为此制定更严格的 Relax NG 条目?
参见 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 Compact 语法的真实示例,请参阅 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>
.