W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2004

Re: Which elements in mixed="true"?

From: <noah_mendelsohn@us.ibm.com>
Date: Thu, 19 Aug 2004 10:38:06 -0400
To: Thomas Solbjør <thomas.solbjor@strath.ac.uk>
Cc: xmlschema-dev@w3.org
Message-ID: <OF7C363129.B8175D26-ON85256EF5.005019AA@lotus.com>

Thomas Solbjør asks:

>> Does the XML Instance document support elements within 
>> an element with: mixed="true"?

>> I'm thinking about formatting elements such as "<b>", 
>> "<h1>" etc.

Not sure which of two sorts of nesting you mean:

<a>
  <b>Maybe some text here?</b>
<a/>

Is supported, but does not involve "mixed content".  You have a 
declaration along the lines of:

<xsd:element name="a">
  <xsd:complexType>
    <xsd:sequence>
        <xsd:element ref="b"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

If you mean nested in text then you do use mixed content:

<a>This text has <b>mixed</b> content <a/>

<xsd:element name="a">
  <!-- allow content to be mixed into text -->
  <xsd:complexType mixed="true">
    <xsd:sequence>
        <xsd:element ref="b"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

As noted in an earlier reply, the way schema implements mixed is that it 
ignores the text children of <a> and validates as if the instance were:

<a><b>mixed</b><a/>

So, you get all the flexibility of sequences, choices, etc., but 
interspersed into text if you like.  Hope this helps.

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------
Received on Thursday, 19 August 2004 14:40:54 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:10 UTC