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

Re: Text and elements as childs?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 14 Oct 2003 14:57:56 +0100
Message-ID: <911470814759.20031014145756@jenitennison.com>
To: "Svend Bent Nielsen" <jawsoap@hotmail.com>
Cc: xmlschema-dev@w3.org

Hi Svend,

> I have looked quite a bit, and have found nothing showing how to
> have elements that can have both text and elements as childs.

This is known as mixed content. You indicate where text is allowed,
intermingled with other elements, using a mixed="true" attribute on
either the <xs:complexType> element or its child <xs:complexContent>
element if it has one. For example:

<xs:element name="author">
  <xs:complextype mixed="true">
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="surname" type="xs:string"/>

Note that this allows text anywhere within the <author> element,
including between the <firstname> and <surname> elements, and after
the <surname> element. If you want to constrain where the text can
appear, you should really change the markup language so that the text
is wrapped in an appropriate element. For example:

  <comment>This is an incompetent author.</comment>



Jeni Tennison
Received on Tuesday, 14 October 2003 09:58:17 UTC

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