Can limit us the level of nesting of a tag?

Hello

I have obligation where a node must be nested in itself. For example:

<root>
     <tab name="T1">
          <tab name="T1.1">
               ...
          </tab>
     </tab>
</root>

I defined the following XSD:

<xsd:element name="tab">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element ref="tfParameters" minOccurs="0" maxOccurs="1"/>
            <xsd:element ref="tfProperties" minOccurs="0" maxOccurs="1"/>
            <xsd:element ref="tab" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:ID"/>
        <xsd:attribute name="refObjectDefId" type="xsd:string"/>
    </xsd:complexType>
</xsd:element>

In the #05 line, I refer to the tab of the new element. I guess that means this tab item can has himself as a child.

What I really want is to ensure that this tab can be nested at once within the item tab. We don't want multi-level nesting. Last option, that I'm looking is to define a new node for the child tab and use it.

Please tell us how can I achieve this.

Thanks in advance for your time.

Matt.

user772606 wrote:

What I really want is to ensure that this tab can be nested at once within the item tab. We don't want multi-level nesting. Last option, that I'm looking is to define a new node for the child tab and use it.

I'm afraid, is not possible using XSD.

You must either:

1 declare two types different 'tab', a parent and a child who does not refer to itself

2 - keep the XSD as is and perform an additional check to apply rule (easily done with XQuery for example)

I choose the #1 option and set the type of parent as an extension of the type of the child, so that you do not have to declare the same structure twice.

Tags: Oracle Development

Similar Questions

Maybe you are looking for