xmlrelaxng

RELAX NG Multiple names for the element with the same structure


Suppose I have two these rules:

JFalse = element JFalse {
   attribute label { xs:string }?,
   attribute jump { xs:string }?,
   attribute offset { xs:integer }?
}

JGt = element JGt {
   attribute label { xs:string }?,
   attribute jump { xs:string }?,
   attribute offset { xs:integer }?
}

(quite a lot more in actuality)

What I'd like to do is obviously something like:

JFalseOrJGt = element (JFalse | JGt) {
   attribute label { xs:string }?,
   attribute jump { xs:string }?,
   attribute offset { xs:integer }?
}

(but the above is not valid). Can I do it in some other way, that will result in a more "compressed" grammar rules?


Solution

  • This is one option:

    JFalse = element JFalse { jFalseGt }
    
    JGt = element JGt { jFalseGt }
    
    jFalseGt = 
       attribute label { xs:string }?,
       attribute jump { xs:string }?,
       attribute offset { xs:integer }?