In XML, "Mixed Content" refers to an element content model that allows both text and child elements within an element. This means that the element can contain both character data (i.e. text content) and child elements in any order. For example, consider an XML element named "paragraph" that can contain both text and a child element named "emphasis":
<!ELEMENT paragraph (#PCDATA | emphasis)*>
<!ELEMENT emphasis (#PCDATA)>
In this example, the "paragraph" element is defined as having mixed content by using the asterisk (*) to indicate that any number of occurrences of either character data or the "emphasis" element can appear in any order. The "emphasis" element is defined as containing only character data.
With this content model, the following are all valid examples of "paragraph" elements:
<paragraph>This is a simple paragraph.</paragraph>
<paragraph><emphasis>This</emphasis> is an <emphasis>important</emphasis> paragraph.</paragraph>
<paragraph><emphasis>This</emphasis> paragraph contains <emphasis>multiple</emphasis> emphases.</paragraph>
Mixed content models can be useful when the content of an element needs to contain both text and other elements, such as in the case of HTML-like markup languages or rich-text document formats. However, they can also make it more difficult to validate and process the XML document, as the order and content of child elements can vary.
Mixed content models enable you to include both text and element content within a single content model.
To create a mixed content model in XML Schemas, simply include the mixed attribute with the value true in your <complexType> definition,
like so: