When you begin using Relax NG to describe mixed content, you can come up with this error in your grammar:
both operands of "interleave" contain "text"
Here is what causes this error. Consider a simple weather report that consists of mixed text, with one or more places, low temperatures, and high temperatures.
<report> Here's your weather report. The temperatures for <place>San Jose</place> will be from <low>75</low> to <high>80</high>. <place>San Francisco</place> will have temperatures ranging from <low>55</low> to <high>60</high>. </report>
Here is a correct Relax NG grammar in compact syntax:
grammar
{
start = element report
{
text &
(
element place { text } &
element low { xsd:integer } &
element high { xsd:integer }
)+
}
}
However, you might think: “There’s text
between the <place>, <low>
and <high>. So shouldn’t I write my grammar
this way:” (lines are numbered for reference; line 5 is
the one you added):
1 grammar {
2 start=element report
3 {
4 text &
5 (
6 text &
7 element place { text } &
8 element low { xsd:integer } &
9 element high { xsd:integer }
10 )+
11 }
12 }
No, you can’t. That will generate the error. You can have
only one {text} defined in an element.
You already have one on line 4; adding the one on line 6 causes
the problem. The {text} on line 7 is just fine,
because it is enclosed in a different element
By the way: the line number in the error message doesn’t give you a clue as to where the error really occurs; you will have to track it down yourself.