W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2002

Re: What are complexContent restrictions made for ?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 17 May 2002 16:44:49 +0100
Message-ID: <46101201359.20020517164449@jenitennison.com>
To: zze-MARCHEGAY Michael stagiaire FTRD/DTL/LAN <michael.marchegay@rd.francetelecom.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi MichaŽl,

> I'm trying to understand the interest of complexContent
> restrictions, but I don't find in which kind of examples it is
> usefull.
[snip]
> I can't figure out what is the difference between an element which
> has type simpleName1 and another which has type simpleName2.
>
> So are complexContents just syntaxic sugar, used by XML Schema
> processing tools or do they have another function?

You're absolutely right that in your example, the simpleName1 and
simpleName2 complex types have exactly the same content model, so
elements of those types are allowed exactly the same content.

However, the fact that simpleName1 is derived from personName can be
significant. For example, if you were to declare an element with the
type personName:

  <xsl:element name="name" type="personName" />

then an instance of that element could be assigned the type
simpleName1 through the xsi:type attribute:

  <name xsi:type="simpleName1">...</name>

whereas it couldn't be assigned the type simpleName2.

Similarly, an element called simpleName could belong to the name
element's substitution group if it had the type simpleName1 (because
that's derived from the name element's type) but not if it had the
type simpleName2.

So within the schema itself, and in terms of what you can do in the
instance document, the fact that one of the types is derived from
personName and the other isn't can make a significant difference.

The other way in which the type hierarchy can help is within
processing tools that are aware of the PSVI. XSLT 2.0, for example, is
on its way to becoming such a tool, which would mean that you'd be
able to match all elements of type personName or simpleName1 with:

<xsl:template match="*[. instance of personName]">
  ...
</xsl:template>

whereas simpleName2 is unrelated to personName.

Thus, deriving by restriction is helpful because it enables you to
express the commonality between a set of elements, and process them in
the same kind of way.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Friday, 17 May 2002 11:44:51 UTC

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