- From: Dare Obasanjo <dareo@microsoft.com>
- Date: Fri, 25 Oct 2002 15:45:07 -0700
- To: <David.Cantrell@Gunter.AF.mil>, <xmlschema-dev@frink.w3.org>
Element with subelements and/or attributes are complex types. Elements that do not contain nested elements but instead a single value have simple content. Every element has to have a type [even if it is xs:anyType]. To add attributes to a complex type with simple content means extending its underlying simple type.
-----Original Message-----
From: David.Cantrell@Gunter.AF.mil [mailto:David.Cantrell@Gunter.AF.mil]
Sent: Fri 10/25/2002 1:48 PM
To: xmlschema-dev@frink.w3.org
Cc:
Subject: extension element question
Hello again schemers,
I am going through the XFront schema tutorial[0] and have hit a spot that I
don't quite understand.
Why are the simpleContent and extension elements required here:
<xsd:complexType name="linkType">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="title"
type="xsd:string" use="required"/>
<xsd:attribute name="action"
type="xsd:string" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
I'm not extending any types, at least not intentionally, so I'm not sure why
it's required. The element I'm trying to create should look like this:
<link title="foo" action="bar"/>
There are no child elements or character data, the element will always be
empty except for the two required attributes.
Also, I don't quite understand exactly what the simpleContent element really
does. The MSXML docs state:
"Contains extensions or restrictions on a complexType element with
character data or a simpleType element as content and contains no elements."
I don't fully understand exactly what that means. Since there is no CDATA
and it is not a simpleType, and definitely does not contain any child
elements, I see no reason for this element to be required.
However, if I eliminate either the extension or the entire simpleContent
wrapper, the validation fails and reports I did not declare a root element
(not shown in the above schema snippet)... :(
Thanks,
-dave
[0] http://www.xfront.com/#schema
Received on Friday, 25 October 2002 18:45:18 UTC