<?xml version="1.0" encoding="UTF-8"?>
<rng:grammar xmlns:rng="http://relaxng.org/ns/structure/1.0">
    <rng:define name="any">
      <rng:element>
        <rng:anyName/>
        <rng:zeroOrMore>
            <rng:choice>
            <rng:attribute>
            <rng:anyName/>
            </rng:attribute>
            <rng:text/>
            <rng:ref name="any"/>
            </rng:choice>
        </rng:zeroOrMore>
        </rng:element>
    </rng:define>

    <rng:define name="value">
        <rng:element name="value">
            <rng:optional><rng:attribute name="model" /></rng:optional>
            <rng:optional><rng:attribute name="search" /></rng:optional>
            <rng:optional>
                <rng:attribute name="eval"/>
            </rng:optional>
            <rng:empty />
        </rng:element>
    </rng:define>

    <rng:define name="function">
        <rng:element name="function">
            <rng:attribute name="model" />
            <rng:attribute name="name" />
            <rng:optional><rng:attribute name="id" /></rng:optional>
            <rng:optional><rng:attribute name="eval" /></rng:optional>
            <rng:optional><rng:attribute name="context" /></rng:optional>
            <rng:choice>
                <rng:empty />
                <rng:oneOrMore>
                    <rng:choice>
                        <rng:ref name="value" />
                        <rng:ref name="function" />
                    </rng:choice>
                </rng:oneOrMore>
            </rng:choice>
        </rng:element>
    </rng:define>

    <rng:define name="assert">
        <rng:element name="assert">
            <rng:attribute name="model" />
            <rng:optional><rng:attribute name="search" /></rng:optional>
            <rng:optional><rng:attribute name="count" /></rng:optional>
            <rng:optional><rng:attribute name="string" /></rng:optional>
            <rng:optional><rng:attribute name="id" /></rng:optional>
            <rng:optional><rng:attribute name="context" /></rng:optional>
            <rng:optional><rng:attribute name="severity" /></rng:optional>
            <rng:zeroOrMore>
                <rng:element name="test">
                    <rng:attribute name="expr"/>
                    <rng:choice>
                        <rng:text />
                        <rng:empty />
                    </rng:choice>
                </rng:element>
            </rng:zeroOrMore>
        </rng:element>
    </rng:define>

    <rng:define name="workflow">
        <rng:element name="workflow">
            <rng:attribute name="model" />
            <rng:optional><rng:attribute name="ref" /></rng:optional>
            <rng:attribute name="action"/>
            <rng:optional><rng:attribute name="uid"/></rng:optional>
            <rng:optional><rng:attribute name="context" /></rng:optional>
            <rng:choice>
                <rng:empty/>
                <rng:ref name="value"/>
            </rng:choice>
        </rng:element>
    </rng:define>

    <rng:define name="wizard">
        <rng:element name="wizard">
            <rng:attribute name="name"/>
            <rng:attribute name="id" />
            <rng:optional><rng:attribute name="menu" /></rng:optional>
            <rng:optional><rng:attribute name="model" /></rng:optional>
            <rng:attribute name="string" />
            <rng:optional><rng:attribute name="keyword" /></rng:optional>
            <rng:optional><rng:attribute name="multi" /></rng:optional>
            <rng:optional><rng:attribute name="client_action_multi" /></rng:optional>
            <rng:optional> <rng:attribute name="groups"/> </rng:optional>
        </rng:element>
    </rng:define>

    <rng:define name="report">
        <rng:element name="report">
            <rng:optional><rng:attribute name="id"/></rng:optional>
            <rng:attribute name="string"/>
            <rng:attribute name="model"/>
            <rng:attribute name="name"/>
            <rng:optional><rng:attribute name="multi"/></rng:optional>
            <rng:optional><rng:attribute name="menu"/></rng:optional>
            <rng:optional><rng:attribute name="keyword"/></rng:optional>
            <rng:optional><rng:attribute name="rml"/></rng:optional>
            <rng:optional><rng:attribute name="sxw"/></rng:optional>
            <rng:optional><rng:attribute name="xml"/></rng:optional>
            <rng:optional><rng:attribute name="xsl"/></rng:optional>
            <rng:optional> <rng:attribute name="auto" /> </rng:optional>
            <rng:optional> <rng:attribute name="header" /> </rng:optional>
            <rng:optional> <rng:attribute name="attachment" /> </rng:optional>
            <rng:optional> <rng:attribute name="attachment_use" /> </rng:optional>
            <rng:optional> <rng:attribute name="groups"/> </rng:optional>
            <rng:empty />
        </rng:element>
    </rng:define>

    <rng:define name="field">
        <rng:element name="field">
            <rng:attribute name="name" />
            <rng:optional><rng:attribute name="type"/></rng:optional>
            <rng:optional><rng:attribute name="ref"/></rng:optional>
            <rng:optional><rng:attribute name="eval"/></rng:optional>
            <rng:optional><rng:attribute name="search"/></rng:optional>
            <rng:optional><rng:attribute name="model"/></rng:optional>
            <rng:optional><rng:attribute name="use"/></rng:optional>
            <rng:oneOrMore>
                <rng:choice>
                    <rng:ref name="any"/>
                    <rng:text/>
                </rng:choice>
            </rng:oneOrMore>
        </rng:element>
    </rng:define>


    <rng:define name="record">
        <rng:element name="record">
            <rng:optional><rng:attribute name="id" /> </rng:optional>
            <rng:attribute name="model" />
            <rng:optional><rng:attribute name="forcecreate" /></rng:optional>
            <rng:zeroOrMore>
                <rng:ref name="field" />
            </rng:zeroOrMore>
        </rng:element>
    </rng:define>

    <rng:define name="delete">
        <rng:element name="delete">
            <rng:attribute name="model" />
            <rng:optional><rng:attribute name="id" /> </rng:optional>
            <rng:optional><rng:attribute name="search" /></rng:optional>
            </rng:element>
    </rng:define>

    <rng:define name="ir_set">
        <rng:element name="ir_set">
            <rng:oneOrMore>
                <rng:ref name="field" />
            </rng:oneOrMore>
        </rng:element>
    </rng:define>

    <rng:define name="menuitem">
        <rng:element name="menuitem">
            <!-- L'identifiant devrait être obligatoire -->
            <rng:optional> <rng:attribute name="id" /></rng:optional>
            <!-- Attention le nom peut disparaitre uniquement si le parent est présent -->
            <rng:optional> <rng:attribute name="name"/></rng:optional>
            <rng:optional> <rng:attribute name="parent"/> </rng:optional>
            <rng:optional> <rng:attribute name="icon"/> </rng:optional>
            <rng:optional> <rng:attribute name="action"/> </rng:optional>
            <rng:optional> <rng:attribute name="string"/> </rng:optional>
            <rng:optional> <rng:attribute name="sequence"/> </rng:optional>
            <rng:optional> <rng:attribute name="groups"/> </rng:optional>
            <rng:optional> <rng:attribute name="type"/> </rng:optional>
            <rng:optional> <rng:attribute name="menu"/> </rng:optional>
            <rng:empty />
        </rng:element>
    </rng:define>

    <rng:define name="act_window">
        <rng:element name="act_window">
            <rng:attribute name="id" />
            <rng:attribute name="name" />
            <rng:attribute name="res_model" />
            <rng:optional><rng:attribute name="domain" /> </rng:optional>
            <rng:optional><rng:attribute name="src_model" /></rng:optional>
            <rng:optional><rng:attribute name="context" /></rng:optional>
            <rng:optional> <rng:attribute name="view"/> </rng:optional>
            <rng:optional> <rng:attribute name="view_id"/> </rng:optional>
            <rng:optional> <rng:attribute name="view_type"/> </rng:optional>
            <rng:optional> <rng:attribute name="view_mode"/> </rng:optional>
            <rng:optional> <rng:attribute name="multi"/> </rng:optional>
            <rng:optional> <rng:attribute name="target"/> </rng:optional>
            <rng:optional> <rng:attribute name="groups"/> </rng:optional>
            <rng:optional> <rng:attribute name="limit"/> </rng:optional>
            <rng:optional> <rng:attribute name="usage"/> </rng:optional>
            <rng:optional> <rng:attribute name="auto_refresh"/> </rng:optional>
            <rng:empty />
        </rng:element>
    </rng:define>

    <rng:define name="data">
        <rng:element name="data">
            <rng:optional><rng:attribute name="noupdate" /></rng:optional>
            <rng:optional><rng:attribute name="context" /></rng:optional>
            <rng:zeroOrMore>
                <rng:choice>
                    <rng:text/>
                    <rng:ref name="menuitem" />
                    <rng:ref name="record" />
                    <rng:ref name="delete" />
                    <rng:ref name="wizard" />
                    <rng:ref name="act_window" />
                    <rng:ref name="assert" />
                    <rng:ref name="report" />
                    <rng:ref name="workflow" />
                    <rng:ref name="function" />
                    <rng:ref name="ir_set" />
                </rng:choice>
            </rng:zeroOrMore>
        </rng:element>
    </rng:define>

    <rng:start>
        <rng:choice>
            <rng:element name="openerp">
                <rng:oneOrMore>
                    <rng:ref name="data" />
                </rng:oneOrMore>
            </rng:element>
            <rng:element name="terp">
                <rng:oneOrMore>
                    <rng:ref name="data" />
                </rng:oneOrMore>
            </rng:element>
        </rng:choice>
    </rng:start>
</rng:grammar>
