Interleave In RNC

浪尽此生 提交于 2019-12-19 12:04:04

问题


I have source with three p with different attribute values, I tried to make arbitrary order of elements along with one mandatory element p class='paragraph1'. That is any number of paragraph1, paragraph2 and pharagraph3 in any order but there must be at least one paragraph1.

Below I tried the interleave option in RNC, but I failed with an error "the element "p" can occur in more than one operand of "interleave"" This is because the same element declared more than one time. But is this possible in RelaxNG using any other method?

Source

<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" } }

来源:https://stackoverflow.com/questions/44111198/interleave-in-rnc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!