XML Tutorial/XML Schema/any
Версия от 18:22, 25 мая 2010; (обсуждение)
Element Wildcards
Suppose you want to specify that your element can contain any of the elements.
Declarations that allow you to include any element from a namespace are called element wildcards.
To declare an element wildcard, use the <any> declaration:
<any minOccurs="non negative number"
maxOccurs="non negative number or unbounded"
namespace="allowable namespaces"
processContents="lax or skip or strict">
You are not allowed to create global <any> declarations.
The namespace attribute allows several values, shown in the following table:
##any allows elements from all namespaces to be included as part of the wildcard
##other allows elements from namespaces other than the targetNamespace to be included as part of ##targetNamespace Allows elements from only the targetNamespaceto be included as part of the wildcard
##local allows any well-formed elements that are not qualified by a name space to be included as part of the wildcard
Whitespace-separated list of allowable namespace URIs allows elements from any listed namespaces to be included as part of
the wildcard. Possible list values also include ##targetNamespace and ##local.
To allow for any content to be used within an element, you have to use the any element:
<xsd:element name="contact">
<xsd:complexType mixed="true">
<xsd:sequence>
<xsd:any maxOccurs="unbounded" processContents="skip"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>