[ACCEPTED]-Difference/similarities between xsd:any and xsd:anyType-xsd

Accepted answer
Score: 32

This post explains it nicely. I quote:

xsd:anyType 17 is a type, like xsd:integer (though xsd:anyType 16 is special in that it can act as a simple or 15 complex type, and it places essentially 14 no restrictions on the tree that it validates 13 -- think of it loosely as the Schema language's analog 12 of java.lang.Object).

A sample use would 11 be:

<xsd:element name="e" type="xsd:anyType"/>

This would mean that elements named <e> can 10 have any content, any attributes, etc.

xs:any 9 is a wildcard, usable as a term in a content 8 model. For example:

<xsd:complexType name="T">
    <xsd:element ref="A"/>
    <xsd:any />
    <xsd:element ref="C"/>

Elements of type T must 7 have content <A/><???/><C/>, where <???> can be any named 6 element. Now, if you look really closely 5 there is an approximation to the definition 4 of xsd:anyType given for reference in 3 the Recommendation, and it uses an xsd:any wildcard 2 as the means of saying that it allows 1 any elements.

Also take a look at the XML Schema.

Score: 31

The mailing list post linked in dogbane's 5 answer wasn't clear to me until I created 4 the following example:

With anyType schema:

<xsd:complexType name="Outer">
    <xsd:element name="e" type="xsd:anyType" />

Which 3 allows this format:

    <e> // must be called "e"
        // but anything can go inside

And with any schema:

<xsd:complexType name="Outer">
    <xsd:any />

Which 2 allows this format:

    //anything can go inside

So anyType is a type, and 1 any is an element

More Related questions