Interleave In RNC

235 views Asked by At

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

There are 0 answers