Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference/similarities between xsd:any and xsd:anyType

Tags:

I am reading about XML, XML-Schema, DTD and I don't really understand the difference between xsd:any and xsd:anyType.

Can someone explain this to me or point to some good article? (please don't link to the XML-Schema specifications - I read that and I'm more confused)

TIA

like image 993
user989812323 Avatar asked Mar 22 '11 09:03

user989812323


People also ask

What is XSD anyType?

The xsd:anyType is the base data type from which all simple and complex data types are derived. It does not restrict the data content.

What is the difference between XML Schema and XSD?

Differences: XSD is based and written on XML. XSD defines elements and structures that can appear in the document, while XML does not. XSD ensures that the data is properly interpreted, while XML does not.

What is difference between XSD and XS?

For brevity, the text and examples in this specification use the prefix xs: to stand for this namespace; in practice, any prefix can be used. in the end xs or xsd are only prefixes. XSD is used for example more by Microsoft schemas. The important is how you declare the namespace.

Is XSD and schema same?

XML Schema is commonly known as XML Schema Definition (XSD). It is used to describe and validate the structure and the content of XML data. XML schema defines the elements, attributes and data types. Schema element supports Namespaces.


1 Answers

This post explains it nicely. I quote:

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

A sample use would be:

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

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

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

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

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

Also take a look at the XML Schema.

like image 72
dogbane Avatar answered Oct 07 '22 17:10

dogbane