Name

xs:element(within xs:all) — Reference to a global element declaration or local definition (local definitions cannot be referenced). The number of occurrences can only be zero or one when xs:element is used within xs:all..

Synopsis

<xs:element
           block         = ( “#all” | list of ( “extension” | “restriction” |
                              “substitution” ) )
           default       = xs:string
           fixed         = xs:string
           form          = ( “qualified” | “unqualified” )
           id            = xs:ID
           maxOccurs     = ( “0” | “1” ) : “1”
           minOccurs     = ( “0” | “1” ) : “1”
           name          = xs:NCName
           nillable      = xs:boolean : “false”
           ref           = xs:QName
           type          = xs:QName
           {any attributes with non-schema namespace}
           >
           Content: (xs:annotation?, (xs:simpleType | xs:complexType)?, (xs:unique |
                     xs:key | xs:keyref)*)
</xs:element>

May be included in: xs:all (outside a group), xs:all (within a group)

Description

This element serves two different purposes and has two different content models for these purposes: it can either be a reference to a globally defined element or to a local element definition. These options are mutually exclusive.

When used as a reference to an element, the ref attribute must contain the qualified name of the element (with its namespace prefix).

When used as a local definition, the definition is done by assigning a simple or complex datatype to the element. This assignment can be done either by reference, using the type attribute to refer to a simple or complex datatype by its qualified name, or inline, by embedding the definition of the simple (xs:simpleType) element or complex (xs:complexType) element within the xs:element element.

Restrictions

Local element definitions or references cannot have a number of occurrences greater than one.

The default and fixed values are defined in attributes and, therefore, can only apply to simple type elements.

The fact that W3C XML Schema cannot describe the exclusive combinations of the attributes and elements of xs:element, which can be summarized as:

ref attribute xor name attribute, type attribute xor xs:simpleType element, xor 
xs:complexType element

is an example that shows some of the restrictions of the language.

Example

<xs:all>
  <xs:element name="first" type="string32" minOccurs="0"/>
  <xs:element name="middle" type="string32" minOccurs="0"/>
  <xs:element name="last" type="string32"/>
</xs:all>

Attributes

block

Controls whether the element can be subject to a type or substitution group substitution. #all blocks any substitution, substitution blocks any substitution through substitution groups, and extension and restriction block any substitution (both through xsi:type and substitution groups) by elements or types, derived respectively by extension or restriction from the type of the element. Its default value is defined by the blockDefault attribute of the parent xs:schema.

default

Default value of the element. Defined in an attribute, element default values must be simple contents. Also note that default values apply only to elements that are present in the document and empty. The fixed and default attributes are mutually exclusive.

fixed

A simple content element may be fixed to a specific value using this attribute. This value is also used as a default value, and if the element is empty, it is supplied to the application. The fixed and default attributes are mutually exclusive.

form

Specifies whether the element must be qualified (i.e., belong to a namespace) in the instance documents or not. The default value of this attribute is determined by the xs:schema elementFormDefault attribute.

id

W3C XML Schema’s element ID.

maxOccurs

Maximum number of occurrences of the element. Can take only the values 0 or 1 within a xs:all compositor.

minOccurs

Minimum number of occurrences of the element. Can take only the values 0 or 1 within a xs:all compositor.

name

Name of the element (mutually exclusive with the ref attribute).

nillable

When this attribute is set to true, the element can be declared as nil using an xsi:nil attribute in the instance documents.

ref

Reference to a global element definition (mutually exclusive with the name, block, and type attributes and any embedded type definition.

type

Simple or complex type of the element (mutually exclusive with the ref attribute and any embedded type definition).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.161.116