XML Schema any element

Definition and usage

The any element allows any element from the specified namespace to be displayed within elements containing sequence or choice.

This element allows the creator to extend the XML document by using elements not specified by the schema.

Element information

Item Description
Number of occurrences Unrestricted
Parent element choice, sequence
Content annotation

Syntax

<any
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
namespace=namespace
processContents=lax|skip|strict
any attributes
>
(annotation?)
</any>

(The '?' symbol indicates that the element can appear zero or one time within any element.)

Attribute

id

Optional. Specifies the unique ID of the element.

maxOccurs

Optional. Specifies the maximum number of times an any element can appear within a parent element. This value can be an integer greater than or equal to zero. If you do not want to set any limit on the maximum number, please use the string "unbounded". The default value is 1.

minOccurs

Optional. Specifies the minimum number of times the any element can appear in the parent element. The value can be any integer greater than or equal to zero. To specify that the any group is optional, set this attribute to zero. The default value is 1.

namespace

Optional. Specifies the namespace of elements that can be used. If no namespace is specified, ##any is the default value. If a namespace is specified, it must be one of the following values:

  • ##any - Elements from any namespace can appear (default).
  • ##other - Elements from any namespace other than the target namespace of the parent element of the element can appear.
  • ##local - Elements not qualified by a namespace can appear.
  • ##targetNamespace - Elements from the target namespace of the parent element containing the element can appear.
  • A list of {URI references of namespaces, ##targetNamespace, ##local} - Elements from the namespace list separated by spaces can appear. The list can contain the following: URI references of namespaces ##targetNamespace and ##local.

processContents

Optional. An indicator that specifies how the application or XML processor should handle the validation of the XML document based on the elements specified by the any element. If the processContents attribute is not specified, the default is strict. If processContents is specified, it must be one of the following values:

  • strict - The XML processor must obtain the schema required for the namespace and must validate all elements from these namespaces. (Default)
  • lax - Same as strict; however, no error occurs even if the schema cannot be obtained.
  • skip - The XML processor does not attempt to validate all elements from the specified namespace.

any attributes

Optional. Specifies any other attributes with non-schema namespaces.

Example

The following example demonstrates a declaration of the "person" element. By using the <any> element, the creator can extend the content of "person" with any element (after <lastname>):

<xs:element name="person">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
      <xs:any minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>