- From: <Noah_Mendelsohn@lotus.com>
- Date: Mon, 19 Feb 2001 10:44:10 -0500
- To: Michael Anderson <michael@research.canon.com.au>
- Cc: xmlschema-dev@w3.org, xmlschemadev@hotmail.com
Michael Anderson writes: >> Is this right? I thought anyType can >> function as a complex type _only_, >> not a simpleType. There are a lot of subtleties in this area, but the simple answer is: " The anyType (the urType) functions as both simple and complex." One way to think about this is to notice that anyType has mixed content, not element only. So, if we have: <element name="A" type="anyType"/> that will validate, among other things, <A><B/><A/> -or - <A>Here is some <emph>interesting</emph> text </A> -or- <A>Here is some text</A> You can see that the last example looks like simple content. In the interest of having a single type hierarchy, that same declaration 48 also validates both of the following: <A>123</A> <A xsi:type="xs:integer">123</A> The first one of these two is just the same as the last of the three above. The second one is where we make the leap that makes it clear that even numeric types such as integer are viewed as restrictions of the urType (anyType). And here is one more fancy example (presuming targetNamespace prefixed by mySchema:): <element name="A" type="anyType"/> <element name="I" type="integer" substitutionGroup="myschema:A"/> <element name="C"> <complexType> <sequence> <!-- the following allows substitution group members too --> <element ref="myschema:A"/> </sequence> </complexType> </element> This will validate both of the following, among others: <C><A>Here is some <emph>interesting</emph> text </A></C> <C><I>123</I></C> Note that the integer element <I> can be in the substitution group of <A> because its type integer is indeed a subtype of the urType. Again, this is very subtle stuff, but it mostly just does what you want. Don't be misled: the urType is magic, just as "Object" is magic in Java. The specification shows you an approximation to the declaration of the urType, but it is just an approximation. This type has characteristics that you cannot express my writing down an ordinary complex type declaration. As noted in the original quote, this type has the unique characteristic that it functions as the root of the derivation tree for all types in the hierarchy, both simple and complex, including mixed. We have given a name to its simple manifestation, anySimpleType, because that is what you need to declare things like attributes that do not allow element content under any circumstances. I hope you find this explanation to be helpful. ------------------------------------------------------------------------ Noah Mendelsohn Voice: 1-617-693-4036 Lotus Development Corp. Fax: 1-617-693-8676 One Rogers Street Cambridge, MA 02142 ------------------------------------------------------------------------
Received on Monday, 19 February 2001 10:56:56 UTC