Reputation: 12158
What's the difference between an unconstrained element, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/import" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a"></xs:element>
</xs:schema>
and an element with type xs:anyType
, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:tns="http://tempuri.org/import" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="b" type="xs:anyType"></xs:element>
</xs:schema>
?
Both allow any content and don't pose constraints. Is there any difference? I've went through the relevant specifications, but those haven't clarified my confusion over the difference over them (if any).
Upvotes: 1
Views: 124
Reputation: 111686
There is no difference.
The default for xs:element/@type
is ur-type, otherwise known as anyType
.
See 3.3.2 XML Representation of Element Declaration Schema Components:
{type definition}: The type definition corresponding to the
<simpleType>
or<complexType>
element information item in the [children], if either is present, otherwise thetype
definition ·resolved· to by the ·actual value· of the type [attribute], otherwise the {type definition} of the element declaration ·resolved· to by the ·actual value· of thesubstitutionGroup
[attribute], if present, otherwise the ·ur-type definition·.
See also 2.2.1.1 Type Definition Hierarchy:
[Definition:] A distinguished complex type definition, the ur-type definition, whose name is anyType in the XML Schema namespace, is present in each ·XML Schema·, serving as the root of the type definition hierarchy for that schema.
Related: XML Schema: what's the default type of an xsd:attribute?
Upvotes: 2