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.
Reference the XSD schema in the XML document using XML schema instance attributes such as either xsi:schemaLocation or xsi:noNamespaceSchemaLocation. Add the XSD schema file to a schema cache and then connect that cache to the DOM document or SAX reader, prior to loading or parsing the XML document.
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.
The nillable attribute can be defined on an xsd:element within an XML schema. It specifies that the xsi:nil attribute is valid for the element. If an XML schema has defined the nillable attribute as true, it is mapped as a required attribute and is included in the document, however, its values are nullified.
Basically it references another element that is declared elsewhere, which may or may not be the same schema document.
For instance, it could come from an externally referenced schema in a different namespace. Suppose you use the item element a lot in several different schemas, you can declare it (and any other common types and attributes) in a common schema, and then reuse those in all your other schemas.
If you reference your common schema with the namespace c, you can declare an instance of the item element on its own or as part of a type as follows:
<xs:element ref="c:item" /><!-- reference here -->
<xs:complexType name="something">
<xs:sequence>
<xs:element ref="c:item" /><!-- and here -->
</xs:sequence>
<xs:element name="other" type="xs:Name" />
</xs:complexType>
The definition in the data schema would look like this:
<xs:element name="item" type="itemType" /><!-- referenced element -->
<xs:complexType name="itemType">
<xs:sequence>
<xs:element name="code" type="xs:Name" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="description" type="xs:normalizedString" use="required" />
</xs:complexType>
For example if you want to declare element types that can appear deeply nested, but also as top level elements in an instance document.
The XML Schema Primer has examples for this: http://www.w3.org/TR/xmlschema-0/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With