define combine="interleave"

This should cover W3C XML Schema, Relax NG and DTD related problems.
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

define combine="interleave"

Post by anayram »

I think there might be a problem with RelaxNG's combine="interleave" pattern in Oxygen.

I defined a "common" schema that contains element definitions used both in schemas "A" and "B". For schema B, I need to redefine a pattern called "narrow-inclusion" (already defined in "common") by allowing the occurrence of three new elements, but XML documents ONLY allow for those three new elements (as if I had replaced the definition, instead of combining by interleave. Below is an example:

In the "common" schema I did the following:

Code: Select all

<define name="narrow-inclusion">
<zeroOrMore>
<choice>
<ref name="A-element"></ref>
<ref name="B-element"></ref>
</choice>
</zeroOrMore>
</define>
And in "B" I redefined "narrow-inclusion" and defined new elements C and D below include (not copied here):

Code: Select all

<include href="common.rng">
<define name="narrow-inclusion">
<zeroOrMore>
<choice>
<ref name="C-element"></ref>
<ref name="D-element"></ref>
</choice>
</zeroOrMore>
</define>
</include>
But XML documents that use B as a schema only allow for C and D. Any help will be greatly appreciated.

Cheers,
Mariana
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

Re: define combine="interleave"

Post by anayram »

My apologies, the second example should read:

Code: Select all

<include href="common.rng">
<define name="narrow-inclusion" [b]combine="interleave"[/b]>
<zeroOrMore>
<choice>
<ref name="C-element"></ref>
<ref name="D-element"></ref>
</choice>
</zeroOrMore>
</define>
</include>
Thanks!
Mariana
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: define combine="interleave"

Post by george »

When you overwrite a pattern inside an include then the old pattern is removed. See
http://relaxng.org/spec-20011203.html#IDAG3YR
If the include element has a define component, then the grammar element must have a define component with the same name. For every define component of the include element, all define components with the same name are removed from the grammar element.
You should place the combine pattern as a sibling of the include element, not as a child. Thus you will get both patterns in your grammar.

Best Regards,
George
George Cristian Bina
anayram
Posts: 17
Joined: Wed Oct 28, 2009 8:35 pm

Re: define combine="interleave"

Post by anayram »

Thank you very much, this solved the issue.

Cheers,
Mariana
Post Reply