• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger
  • Frits Walraven

ANY, anyType, <xsd:any>

Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone say the differences and similarities
among the following three?
XML Schema 1:
<xsd:element name="aName" type="xsd:AnyType" >
XML schema 2:
<xsd:element name=”aName”>
<xsd:complexType mixed=”true” >
<xsd:any minOccures=”1” maxOccures=”unbounded” processContents=”skip” />
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jane,
The question seems to be very interesting. I referred to the XML Schema Part 0 Primer at wc.org
http://www.w3.org/TR/xmlschema-0 and found that all the three are equivalent.
The second one has I suppose is more flexible content model in the sense that it allows HTML content also.
Plese refer to http://www.w3.org/TR/xmlschema-0 for explanation on xsd:anyType and xsd:any element declarations.
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elements declared with the category keyword ANY, can contain any
combination of parsable data.ANY means that the element can contain
zero or more child elements of any declared type, as well as character
data. It is therefore a shorthand for mixed content containing all
declared elements.
AnyType is the default type when the type is not specified and hence this
type doesn't constrain the content of the element.
The <any> element enables us to extend the XML document with elements
not specified by the schema.
The following example is a fragment from an XML schema called
"family.xsd". It shows a declaration for the "person" element.
By using the <any> element we can extend (after <lastname> the content
of "person" with any element:
<xs:element name="person">
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:any minOccurs="0"/>
Now we want to extend the "person" element with a "children" element.
In this case we can do so, even if the author of the schema above
never declared any "children" element!
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's very good explanation
Thanks for the description.
    Bookmark Topic Watch Topic
  • New Topic