[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Who can implement W3C XML Schema ?


xml complextype complexcontent
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@s...]
> Sent: Friday, March 22, 2002 10:58 AM
> To: Thomas B. Passin; xml-dev@l...
> Subject: RE:  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>
> 

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.