How is AppInfo and Documentation element used in and XML Schema?

XML Schema language allows addition of annotations to schema components through an 'annotation' element (<xsd:annotation>) which must contain either a documentation element (<xsd:documentation>) or appInfo element (<xsd:appInfo>).  A source attribute may be added to either element to provide a URL reference to the source of the annotation. Annotations provide a way to provide documentation and application information that may be parsed and accessed by applications via an application program interface (API).

The appInfo element can be used to provide information for tools, StyleSheets and other applications. Both documentation and appInfo appear as sub-elements of annotation, which usually is placed at the beginning of most schema constructions.

The appinfo element is subject to the same rules for appearing in an XML Schema as the documentation element, as they are both contained in the annotation element. This means that it can be used within most schema constructs. In the following example we have nested some script inside the appinfo element, which is intended to indicate to an application what action to take, depending upon which of a choice of two elements a document instance contains:

<xs:group name="CreditOrDebitGroup">
if (currentNode.firstChild != "Credit")
document.write("Your account will be credited within 24
<xs:element name = "Credit" type = "CreditType" />
<xs:element name = "Debit" type = "DebitType" />