XML Schema anyAttribute element
Definition and usage
The anyAttribute element allows creators to extend XML documents through attributes not specified by the schema.
Element information
Item | Description |
---|---|
Occurrence times | Unrestricted |
Parent element | complexType, restriction (simpleContent), extension (simpleContent), restriction (complexContent), extension (complexContent), attributeGroup |
Content | annotation |
Syntax
<anyAttribute id=ID namespace=namespace processContents=lax|skip|strict any attributes > (annotation?) </anyAttribute>
(The ? symbol indicates that the element can appear zero or one time within the anyAttribute element.)
Attributes
id
Optional. Specifies the unique ID of the element.
namespace
Optional. Specifies the namespace of the elements that can be used. If no namespace is specified, the default is ##any. 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 to the 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 for the required 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 a non-schema namespace.
Example
The following example demonstrates a declaration for the "person" element. By using the <anyAttribute> element, the creator can add any number of attributes to the "person" element:
<xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:sequence> <xs:anyAttribute/> </xs:complexType> </xs:element>