- From: Costello, Roger L. <costello@mitre.org>
- Date: Tue, 18 Dec 2012 12:41:58 +0000
- To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hi Folks,
Suppose that you want to create a <comment> element. Its content is string data and it has an attribute, xml:lang.
Here is a sample instance:
<comment xml:lang="en">This is a comment</comment>
One way to declare the <comment> element is as a complexType with simpleContent:
<xs:element name="comment">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="xml:lang" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Interestingly, there is a second way. Declare the <comment> element as a complexType with mixed content:
<xs:element name="comment">
<xs:complexType mixed="true">
<xs:sequence/>
<xs:attribute ref="xml:lang" use="required" />
</xs:complexType>
</xs:element>
Those are two equivalent ways of declaring an element with string content and an attribute.
Neat!
For the second way, notice the empty <sequence> element. From my reading of section 3.4.2.3.3 (bullet 3 in the mapping summary box) it appears that anything but an empty <sequence> element is an invalid schema. Thus, an empty <choice> or <all> element is invalid. However, when I replace the <sequence/> element with <choice/> or <all/> I get no error. Is my schema validator in error, or am I misinterpreting the specification?
/Roger
Received on Tuesday, 18 December 2012 12:42:34 UTC