交织在RNC中

时间:2017-05-22 11:01:42

标签: schema relaxng relaxng-compact

我有三个具有不同属性值的p源代码,我试图将一个元素的任意顺序与一个必需元素p class ='paragraph1'组合在一起。这是任何数量的第1段,第2段和第3段,但必须至少有一个第1段。

下面我尝试了RNC中的interleave选项,但是我失败并出现错误“元素”p“可能出现在”interleave“的多个操作数中”这是因为同一个元素声明了多次。但是,使用任何其他方法可以在RelaxNG中实现吗?

来源

<body>
<h1 class="title">title</h1>
<h2 class="subtitle">subtitle</h2>
<p class="paragraph2">Para text 2</p>
<p class="paragraph1">para text 1</p>
<p class="paragraph3">Para text 2</p>
</body>

RNC

start = element body { h1?, h2?, (p.paragraph1+ & p.paragraph2? & 
 p.paragraph3?) }
 h1 = element h1 { text & attribute class { string } }
 h2 = element h2 { text & attribute class { string } }
 p.paragraph1 = element p { text & attribute class { string "paragraph1" } }
 p.paragraph2 = element p { text & attribute class { string "paragraph2" } }
 p.paragraph3 = element p { text & attribute class { string "paragraph3" } }

0 个答案:

没有答案