You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by stef amerio <am...@hotmail.com> on 2006/03/01 18:54:30 UTC
Inheritance and xsd restriction
Hello,
I have defined a "Folder" of "references" to "Items", a "Folder" being
itself an "Item" :
<complexType name="Item">
<attribute name="Guid" type="string"/>
</complexType>
<complexType name="Folder">
<complexContent>
<extension base="Item">
<sequence>
<element name="Ref" type="Guid" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>
Now, I want to define a "RootFolder", as being a "Folder" with a specific
Guid :
<complexType name="RootFolder">
<complexContent>
<restriction base="Folder">
<attribute name="Guid" type="string" fixed="ROOT"/>
</restriction>
</complexContent>
</complexType>
This does not work. The xmlbeans validation tells me that RootFolder cannot
contains Ref elements.
What I am doing wrong here ?
Thank you for your help.
PS : I _need_ that RootFolder class be a Folder
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: Inheritance and xsd restriction
Posted by Edward Frederick <ep...@gmail.com>.
Stef,
Unlike extension, you must redefine everything from the base type in
the derived type, further restricting the definition as you see fit
(as opposed to just placing the things you want to change).
http://www.w3.org/TR/2000/CR-xmlschema-0-20001024/#DerivByRestrict
4.4 Deriving Complex Types by Restriction
....<b>Notice that types derived by restriction must repeat all the
components of the base type definition:</b>...
Your situation is complicated considering the bit you want to restrict
is injected by extension of yet another type. In any case, that's your
general problem.
Good luck!
Ed
<complexType name="RootFolder">
<complexContent>
<restriction base="Folder">
<attribute name="Guid" type="string" fixed="ROOT"/>
</restriction>
</complexContent>
</complexType>
On 3/1/06, stef amerio <am...@hotmail.com> wrote:
> Hello,
>
> I have defined a "Folder" of "references" to "Items", a "Folder" being
> itself an "Item" :
>
> <complexType name="Item">
> <attribute name="Guid" type="string"/>
> </complexType>
>
> <complexType name="Folder">
> <complexContent>
> <extension base="Item">
> <sequence>
> <element name="Ref" type="Guid" minOccurs="0"
> maxOccurs="unbounded"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
>
> Now, I want to define a "RootFolder", as being a "Folder" with a specific
> Guid :
>
> <complexType name="RootFolder">
> <complexContent>
> <restriction base="Folder">
> <attribute name="Guid" type="string" fixed="ROOT"/>
> </restriction>
> </complexContent>
> </complexType>
>
> This does not work. The xmlbeans validation tells me that RootFolder cannot
> contains Ref elements.
> What I am doing wrong here ?
> Thank you for your help.
>
> PS : I _need_ that RootFolder class be a Folder
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org