[relaxng-user] Interleaving optional elements

jcowan at reutershealth.com jcowan at reutershealth.com
Tue Apr 20 20:28:32 ICT 2004


Erik Bruchez scripsit:

> Is the following Relax NG fragment supposed to work? I don't see any
> reason why it shouldn't but MSV gives me the following error:
> 
>   more than one branch of <interleave> accepts the element "property"

MSV is correct.  One of the few restrictions imposed on RNG for the
sake of implementation is that it must be possible to determine, when
dealing with interleaved streams of elements, which element belongs to
which stream solely by looking at the element name.  It's not allowed
to distinguish the stream members on the basis of their attributes or
child elements.  (For this purpose, text is treated like an element:
it's only allowed in one of the streams.)

Fortunately for you, you have only three cases, so the permutational
explosion is modest:

type1 = element property {
		attribute name {"name1"}, attribute value {xsd:anyURI}}
type2 = element property {
		attribute name {"name2"}, attribute value {xsd:integer}}
type3 = element property {
		attribute name {"name3"}, attribute value {xsd:string}}
allthree = (type1?, type2?, type3?) | (type2?, type1?, type3?) |
	   (type1?, type3?, type2?) | (type3?, type1?, type2?) |
	   (type2?, type3?, type1?) | (type3?, type2?, type1?)

Now if you really have 39 cases, your best hope is to loosen the content
model (accept more documents than you really want):

all39 = (type1 | type2 | type3 | ... | type39)*

-- 
John Cowan  jcowan at reutershealth.com  www.ccil.org/~cowan  www.reutershealth.com
"If I have not seen as far as others, it is because giants were standing
on my shoulders."
        --Hal Abelson


More information about the relaxng-user mailing list