Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Schema: what's the default type of an xsd:attribute?

Tags:

xml

xsd

In EBUCore schema (http://en.wikipedia.org/wiki/Metadata_standards) there is an attribute named 'version' defined as

<attribute name="version" default="1.5">
  <annotation>
    <documentation> The version of the schema for e.g. OAI management.</documentation>
  </annotation>
</attribute>

As you see, there is no 'type' defined for it and I wonder, what's the default type for it - anyType, anySimpleType, string, float, double, ...

W3C spec (http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#section-Built-in-Simple-Type-Definition) is a bit hard to get through:

The ·simple ur-type definition· is considered to have an unconstrained lexical space, and a value space consisting of the union of the value spaces of all the built-in primitive datatypes and the set of all lists of all members of the value spaces of all the built-in primitive datatypes.

So, maybe someone can tell me, which type to map this attribute to?

like image 695
x y Avatar asked Apr 24 '15 11:04

x y


People also ask

What is default maxOccurs in XSD?

The default value for both the minOccurs and the maxOccurs attributes is 1. Thus, when an element such as comment is declared without a maxOccurs attribute, the element may not occur more than once.

What are attributes in XSD?

An attribute provides extra information within an element. Attributes are defined within an XSD as follows, having name and type properties. An Attribute can appear 0 or 1 times within a given element in the XML document. Attributes are either optional or mandatory (by default the are optional).

What is XML attribute type?

The XML attribute is a part of an XML element. The addition of attribute in XML element gives more precise properties of the element i.e, it enhances the properties of the XML element. In the above syntax element_name is the name of an element which can be any name.

What is XSD element type?

XSD elements can be of type simpleType , complexType , or anyType . An element of type simpleType contains only text. It cannot have attributes and elements. An element of type complexType can contain text, elements, and attributes.


1 Answers

Attribute Default Type

The type of XML attributes in XSD defaults to xsd:anySimpleType.

Where's it say that?

3.2.2 XML Representation of Attribute Declaration Schema Components

The simple type definition corresponding to the element information item in the [children], if present, otherwise the simple type definition ·resolved· to by the ·actual value· of the type [attribute], if present, otherwise the ·simple ur-type definition·.

Then, you can find the connection between simple ur-type definition and xsd:anySimpleType here:

[Definition:] The simple ur-type definition is a special restriction of the ur-type definition whose name is anySimpleType in the XML Schema namespace. anySimpleType can be considered as the ·base type· of all ·primitive· datatypes.

Yep, one would have hoped it'd have been easier to determine.

Element Default Type

The type of XML elements in XSD defaults to ur-anytype.

like image 58
kjhughes Avatar answered Oct 21 '22 06:10

kjhughes