OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Who can implement W3C XML Schema ?

[ Lists Home | Date Index | Thread Index ]

Okay, I wrote my previous message at 3:30 am, but now I'm actually ready to
think about this cute little issue.

It's an interesting one, because (as it's been noted previously in this
thread), the anyType is both simple and complex. 

If we treat the anyType as complex in the following:

<element name="myElem">
	<complexType>
		<complexContent>
			<restriction base="anyType"/>
		</complexContent>
	</complexType>
</element>

we can come to the (correct) conclusion that since none of the (infinite)
members of the anyType are mentioned, no element or attribute content is
allowed for myElem. There's a related example in the Primer (2.5.3):

<xsd:element name="internationalPrice">
 <xsd:complexType>
  <xsd:complexContent>
   <xsd:restriction base="xsd:anyType">
    <xsd:attribute name="currency" type="xsd:string"/>
    <xsd:attribute name="value"    type="xsd:decimal"/>
   </xsd:restriction>
  </xsd:complexContent>
 </xsd:complexType>
</xsd:element>

which is equivalent to:

<xsd:element name="internationalPrice">
 <xsd:complexType>
  <xsd:attribute name="currency" type="xsd:string"/>
  <xsd:attribute name="value"    type="xsd:decimal"/>
 </xsd:complexType>
</xsd:element>


The internationalPrice element contains these two attributes, no child
elements, and no data content. I remember checking the normative spec on
this and the primer appears to be correct.

But what is interesting is the simpleType nature of anyType.  One could see
an (incorrect) implemenation regarding the following to definitions as being
equivalent:

<elementname="myElem">
	<complexType>
		<complexContent>
			<restriction base="anyType"/>
		</complexContent>
	</complexType>
</element>


<element name="myElem" type="anySimpleType"/>

And why not? The former definition merely restricts the children and
attributes of a complex type by omitting them. But what of the data content?
If you look at 2.2.1 of Part 1 of the spec, you see:

[Definition:]  A distinguished ur-type definition is present in each ·XML
Schema·, serving as the root of the type definition hierarchy for that
schema. The ur-type definition, whose name is anyType, has the unique
characteristic that it can function as a complex or a simple type
definition, according to context. Specifically, ·restrictions· of the
ur-type definition can themselves be either simple or complex type
definitions. 

I still don't think that treating the two declarations above as equivalent
is correct, but the following would be equivalent according to my
understanding:

<elementname="myElem" mixed="true">
	<complexType>
		<complexContent>
			<restriction base="anyType"/>
		</complexContent>
	</complexType>
</element>

<element name="myElem" type="anySimpleType"/>


However, I'm traipsing into corner cases here, so I would gladly defer to
those true spec mavens out there who spend a lot of time teasing things out
of the spec.  I aim squarely at the 80/20 point.  Implementors of validating
tools unfortunately don't have that luxury.

Ciao,

Jeff


> -----Original Message-----
> From: Jeff Lowery [mailto:jlowery@scenicsoft.com]
> Sent: Friday, March 22, 2002 10:58 AM
> To: Thomas B. Passin; xml-dev@lists.xml.org
> Subject: RE: [xml-dev] Who can implement W3C XML Schema ?
> 
> 
> Hey, why single me out? If Eric isn't sure, how likely am I to be?
> 
> "According to my understanding" (and how it's written in _my_ 
> book [watch
> the elbows, Eric]), the element's content must be empty, since the
> restriction reiterates nothing of the anyType. But somebody 
> pointed out an
> errata somewhere so my interpretation may be suspect. But I 
> think it's what
> the primer has, also. (I'd check, but my laptop's battery is 
> crapping out.)
> 
> > Jeff Lowery, how about explaining this for us?
> > 
> > Cheers,
> > 
> > Tom P
> > 
> > 
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > initiative of OASIS <http://www.oasis-open.org>
> > 
> > The list archives are at http://lists.xml.org/archives/xml-dev/
> > 
> > To subscribe or unsubscribe from this list use the subscription
> > manager: <http://lists.xml.org/ob/adm.pl>
> > 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
> 




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS