Re: Text and elements as childs?

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"/>
  </xs:complextype>
</xs:element>

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:

<author>
  <comment>This is an incompetent author.</comment>
  <firstname>Svend</firstname>
  <surname>Nielsen</surname>
</author>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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