Re: Extending enumerated simple content of complex types

"Hugh Wallis" <hugh_wallis@hyperion.com> writes:

> As a corollary to my earlier question on successive restriction of simple
> content in complex types:
> 
> In my xbrli namespace I have the following type:
> 
>  <complexType name="stringItemType">
>   <simpleContent>
>    <extension base="string">
>     <attribute name="nonNumericContext" type="IDREF" use="required"/>
>     <anyAttribute namespace="##other" processContents="lax"/>
>    </extension>
>   </simpleContent>
>  </complexType>
> 
> I now define a new type in my dt namespace as follows:
> 
>  <complexType name="accountTypeItemType">
>   <simpleContent>
>    <restriction base="xbrli:stringItemType">
>     <enumeration value="account"/>
>     <enumeration value="bank"/>
>     <enumeration value="employee"/>
>     <enumeration value="customer"/>
>    </restriction>
>   </simpleContent>
>  </complexType>
> 
> 
> Suppose I now want to define another type in another namespace that has as
> simpleContent the enumerations from dt:accountTypeItemType and, in addition:
> 
>     <enumeration value="job"/>
>     <enumeration value="vendor"/>
>     <enumeration value="fixed-asset"/>
> 
> What is the best way to do this? I would like the resulting type to derive
> from xbrli:stringItemType but I want to have a modular system that doesn't
> require me to re-enumerate the list from accountTypeItemType in my new type.
> Is this even possible in XML Schema?

Yes, but only if you know in advance that you're going to do this --
restrictions must be explicitly restrictions, if you see what I mean.
Otherwise you could do it with a union after the fact, as it were.

Then pull merge you first (aTIT) enumerations and the new ones as a named
simple type:

<simpleType name="manyItemTypes">
   <restriction base="string">
    <enumeration value="account"/>
    <enumeration value="bank"/>
    <enumeration value="employee"/>
    <enumeration value="customer"/>
    <enumeration value="job"/>
    <enumeration value="vendor"/>
    <enumeration value="fixed-asset"/>
   </restriction>
</simpleType>

Then restrict _that_ in aTIT:

 <complexType name="accountTypeItemType">
  <simpleContent>
   <restriction base="xbrli:stringItemType">
    <simpleType>
     <restriction base="my:manyItemTypes">
      <enumeration value="account"/>
      <enumeration value="bank"/>
      <enumeration value="employee"/>
      <enumeration value="customer"/>
     </restriction>
    </simpleType>
   </restriction>
  </simpleContent>
 </complexType>

It would be nicer to use a union:

<simpleType name="moreItemType">
 <union memberTypes="my:accountItemTypes">
  <simpleType>
    <restriction base="string">
     <enumeration value="job"/>
     <enumeration value="vendor"/>
     <enumeration value="fixed-asset"/>
    </restriction>
  </simpleType>
 </union>
</simpleType>

but that's not a explicitly restriction of string, so it won't work.

Note if I were you I'd use 'token' rather than 'string' throughout.

Hope this helps a bit.

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                      Half-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/
 [mail really from me _always_ has this .sig -- mail without it is forged spam]

Received on Wednesday, 26 March 2003 05:07:56 UTC