W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2003

Complex types - How to define a template to be derived?

From: Chizzolini Stefano <chist@csb.it>
Date: Thu, 2 Oct 2003 19:18:53 +0200
Message-ID: <F4AA32DE20F3D211BCB90050044B6DD07E3784@CSB>
To: xmlschema-dev@w3.org

Hello

I'm puzzled by the need to derive complex-type subelements selectively,
keeping unmodified the complex type itself!

The content model of the "book" complex type should be predefined (all the
elements it contains ("header") and their subelements ("title", "owner",
"keyset" and "extraInfo") should appear when instanced), but it should also
be unusable without being derived.
I say: the "book" complex type should be a template, some elements of whose
("keyset" and "extraInfo") should be derived coherently, while others
("header", "title" and "owner") should remain untouched. So, I could have a
"book" derived-type for poems (keyset subelements would be "date" and
"topic"; extraInfo subelements would be "pages" and "price"), another for
essays (keyset subelements would be "university", "year"; extraInfo
subelements would be "url", "authors" and "contributors") and so on...

Here are the examples (pseudo-schemas and instances):

PSEUDO-SCHEMA

- This is a rough representation of the TEMPLATE to be derived (note that
keyset and extraInfo have no subelements):
<?xml version="1.0"?>
<books generator="">
 <book type="" id="">
  <header>
   <title></title>
   <owner></owner>
   <keyset>
   </keyset>
   <extraInfo>
   </extraInfo>
  </header>
 </book>
</books>

- This is a rough representation of the POEM BOOK (derived from the book
complex-type template):
 <book type="poem" id="">
  <header>
   <title></title>
   <owner></owner>
   <keyset>
    <date></date>
    <topic></topic>
   </keyset>
   <extraInfo>
    <pages></pages>
    <price></price>
   </extraInfo>
  </header>
 </book>

- This is a rough representation of the ESSAY BOOK (derived from the book
complex-type template):
 <book type="essay" id="">
  <header>
   <title></title>
   <owner></owner>
   <keyset>
    <university></university>
    <year></year>
   </keyset>
   <extraInfo>
    <url></url>
    <authors></authors>
    <contributors></contributors>
   </extraInfo>
  </header>
 </book>

INSTANCES

- An instance of the poem book:
 <book type="poem" id="3289033934">
  <header>
   <title>Green Dale</title>
   <owner>Mario Rossi</owner>
   <keyset>
    <date>14/6/2003</date>
    <topic>Country ballad</topic>
   </keyset>
   <extraInfo>
    <pages>12</pages>
    <price>8</price>
   </extraInfo>
  </header>
 </book>

- An instance of the essay book:
 <book type="essay" id="64334432323">
  <header>
   <title>Black Holes</title>
   <owner>Jack L. Jackson</owner>
   <keyset>
    <university>MIT</university>
    <year>2001</year>
   </keyset>
   <extraInfo>
    <url>http://www.mySite.org/essays/blackHoles.htm</url>
    <authors>So many!!</authors>
    <contributors>Many more!!</contributors>
   </extraInfo>
  </header>
 </book>

How can I define a template and derive it?
Please, do you have any suggestion about this?

Thank you!

Stefano Chizzolini
Received on Friday, 3 October 2003 09:29:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:40 GMT