W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2009

Extending Types

From: Flavio Cordova <flavio.cordova@gmail.com>
Date: Tue, 1 Dec 2009 10:34:19 -0200
Message-ID: <5608fb200912010434g8e805a7o30eb11d898199c1d@mail.gmail.com>
To: xmlschema-dev@w3.org
Hello People...

I'm not being able to work with extended types and after some hours
trying to find a solution, I decided to ask for help.. :)

here's the problem..

I have an XML that looks like this:

<MyMessage>
  <HeaderInfo>
     ....
  </HeaderInfo>
  <BusinessContent>
    #someSpecificInformation# <!-- This will be defined in a "child" XSD
    <GenericInfo>
       <information>a</information>
    </GenericInfo>
  </BusinessContent>
</MyMessage>

In a file called definition.xsd, I defined the whole structure,
including the BusinessContent ComplexType.. Then, I defined another
XSD, called item.xsd, where I'd like to define only the content of the
BusinessContent, so I did something like this:

<xs:include schemaLocation="definition.xsd"></xs:include>
<xs:complexType name="BusinessContentTypeImpl">
  <xs:complexContent>
    <xs:extension base="GenericBusinessContentType">
      <xs:sequence>
        <xs:element name="Code" type="xs:string"></xs:element>
        <xs:element name="Description" type="xs:string"></xs:element>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

When I create an XML (adding tags Code and Description), I get an
error because tags Code and Description are not valid children for
BusinessContent, although I've extended it...

I'd also like to force extension of BusinessContent. Then I tried to
use the abstract attribute, but then I couldn't add the <GenericInfo>
child...

So, my questions are:
1) how should I extend BusinessContent (GenericBusinessContentType) so
I could keep the current elements (GenericInfo) add more elements..
2) how could I force a "child" xsd file to import the definitions.xsd
and extend BusinessContent.

Thanks !
Received on Tuesday, 1 December 2009 13:46:21 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:17 UTC