w3schools    w3Schools
Search W3Schools :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
Schema Tutorial
XSD HOME
XSD Intro
XSD Why Use
XSD How To
XSD <schema>

Simple Types
XSD Elements
XSD Attributes
XSD Restrictions

Complex Types
XSD Elements
XSD Empty
XSD Elements Only
XSD Text Only
XSD Mixed
XSD Indicators
XSD <any>
XSD <anyAttribute>
XSD Substitution
XSD Example

Data Types
XSD String
XSD Date
XSD Numeric
XSD Misc

XSD Editor
XSD Summary

References
XSD Reference
XSD Validator

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Tutorials
W3Schools Forum

Helping W3Schools

 

XML Schema element Element


XML Schema Reference Complete XML Schema Reference

Definition and Usage

The element element defines an element.

Element Information

  • Parent elements: schema, choice, all, sequence, group

Syntax

<element
id=ID 
name=NCName
ref=QName
type=QName
substitutionGroup=QName
default=string
fixed=string
form=qualified|unqualified
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
nillable=true|false
abstract=true|false 
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>
annotation?,((simpleType|complexType)?,(unique|key|keyref)*))
</element>

(The ? sign declares that the element can occur zero or one time, and the * sign declares that the element can occur zero or more times inside the element element)

Attribute Description
id Optional. Specifies a unique ID for the element
name Optional. Specifies a name for the element. This attribute is required if the parent element is the schema element
ref Optional. Refers to the name of another element. The ref attribute can include a namespace prefix. This attribute cannot be used if the parent element is the schema element
type Optional. Specifies either the name of a built-in data type, or the name of a simpleType or complexType element
substitutionGroup Optional. Specifies the name of an element that can be substituted with this element. This attribute cannot be used if the parent element is not the schema element
default Optional. Specifies a default value for the element (can only be used if the element's content is a simple type or text only)
fixed Optional. Specifies a fixed value for the element (can only be used if the element's content is a simple type or text only)
form Optional. Specifies the form for the element. "unqualified" indicates that this attribute is not required to be qualified with the namespace prefix. "qualified" indicates that this attribute must be qualified with the namespace prefix. The default value is the value of the elementFormDefault attribute of the schema element. This attribute cannot be used if the parent element is the schema element
maxOccurs Optional. Specifies the maximum number of times this element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1. This attribute cannot be used if the parent element is the schema element
minOccurs Optional. Specifies the minimum number of times this element can occur in the parent element. The value can be any number >= 0. Default value is 1. This attribute cannot be used if the parent element is the schema element
nillable Optional. Specifies whether an explicit null value can be assigned to the element. True enables an instance of the element to have the null attribute set to true. The null attribute is defined as part of the XML Schema namespace for instances. Default is false
abstract Optional. Specifies whether the element can be used in an instance document. True indicates that the element cannot appear in the instance document. Instead, another element whose substitutionGroup attribute contains the qualified name (QName) of this element must appear in this element's place. Default is false
block Optional. Prevents an element with a specified type of derivation from being used in place of this element. This value can contain #all or a list that is a subset of extension, restriction, or equivClass:
  • extension - prevents elements derived by extension
  • restriction - prevents elements derived by restriction
  • substitution - prevents elements derived by substitution
  • #all - prevents all derived elements
final Optional. Sets the default value of the final attribute on the element element.  This attribute cannot be used if the parent element is not the schema element. This value can contain #all or a list that is a subset of extension or restriction:
  • extension - prevents elements derived by extension
  • restriction - prevents elements derived by restriction
  • #all - prevents all derived elements
any attributes Optional. Specifies any other attributes with non-schema namespace

Example 1

The following example is a schema with four simple elements named "fname", "lname", "age", and "dateborn", which are of type string, nonNegativeInteger, and date:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="fname" type="xs:string"/>
<xs:element name="lname" type="xs:string"/>
<xs:element name="age" type="xs:nonNegativeInteger"/>
<xs:element name="dateborn" type="xs:date"/>
</xs:schema>

Example 2

The following example is a schema with an element named "note" that is of a complex type. The "note" element contains four other simple elements; "to", "from", "heading", and "body":

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
    <xs:complexType>
      <xs:sequence>
	<xs:element name="to" type="xs:string"/>
	<xs:element name="from" type="xs:string"/>
	<xs:element name="heading" type="xs:string"/>
	<xs:element name="body" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>

Example 3

This example is equal to Example 2, but here we have chosen to use the ref attribute to refer to the element names:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="to"/>
      <xs:element ref="from"/>
      <xs:element ref="heading"/>
      <xs:element ref="body"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:schema>


XML Schema Reference Complete XML Schema Reference


Altova® XMLSpy® - The world's best-selling XML editor!

Whether you're new to XML or already an advanced user, the user-friendly views and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to meet your XML and Web services development needs from start to finish.

  • XML editor
  • Graphical XML Schema / DTD editors
  • XSLT 1.0/2.0 editor, debugger, profiler
  • XQuery editor, debugger, profiler
  • Support for Office Open XML (OOXML)
  • Graphical WSDL editor & SOAP debugger
  • Java, C#, C++ code generation
  • And much more!

Download a fully functional free 30-day trial today!



 
WEB HOSTING
ASP.NET Web Hosting
ASP.NET
Web Hosting
$15 Domain Name
Registration
Save $20 / year!
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Download XML editor
FREE Flash Website
FREE Web Templates
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
Home HOME or Top of Page Validate   Validate   W3C-WAI level A conformance icon Printer Friendly  Printer Friendly

W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user.
While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright 1999-2009 by Refsnes Data. All Rights Reserved.