define combine="interleave"

This should cover W3C XML Schema, Relax NG and DTD related problems.
anayram
Posts: 17

define combine="interleave"

Thu Apr 08, 2010 9:12 pm

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

Re: define combine="interleave"

Thu Apr 08, 2010 9:14 pm

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: 2100

Re: define combine="interleave"

Sun Apr 11, 2010 10:46 pm

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

Re: define combine="interleave"

Tue Apr 13, 2010 10:37 pm

Thank you very much, this solved the issue.

Cheers,
Mariana

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 1 guest