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

Re: Empty Complex Type; Mixed Content Type

  • From: Martin Gudgin <marting@d...>
  • To: Martin Gudgin <marting@d...>, ramesh@e..., xml-dev@x...
  • Date: Sun, 01 Oct 2000 22:26:20 +0100

xsd empty element
After further study and converse with other WG members I must retract my
earlier assertion about the example in the XML Schema Part 0 - Primer[1]

The example in the Primer ( shown below ) is correct. An explanation of why
seems to be in order...

<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>

It might seem strange to add attributes during a restriction but really it's
no different from the element case.

e.g.

<complexType name='foo'>
  <element name='bar' type='string' />
  <element name='baz' type='string' />
</complexType>

is implicitly a restriction or the ur-type ( xsd:anyType is implicitly the
base ). What is being restricted is the <xsd:any> that appears in the
ur-type. We're saying it's no longer the case the any element can appear but
rather that it must be a bar element followed by a baz element.

The ur-type also contains an <xsd:anyAttribute> so the similar attribute
case would be;

<complexType name='foo'>
  <attribute name='bar' type='string' />
  <attribute name='baz' type='string' />
</complexType>

Here we are restricting the valid attributes from any attributes to a bar
attribute and a baz attribute.

The primer example uses this latter approach and hence is a valid type
description.

I have confirmed that the ur-type cannot be extended.

Sorry for misinformation in my previous post ( although the stuff about
mixed content still stands )

Regards

Martin Gudgin
DevelopMentor

[1] http://www.w3.org/TR/xmlschema-0




----- Original Message -----
From: "Martin Gudgin" <marting@d...>
To: <ramesh@e...>; <xml-dev@x...>
Sent: Sunday, October 01, 2000 7:43 PM
Subject: Re: Empty Complex Type; Mixed Content Type


> I believe that this is an error and have mailed the editor of the primer
> suggesting the following modification
>
> <xsd:element name="internationalPrice">
>  <xsd:complexType>
>   <xsd:complexContent>
>    <xsd:restriction>
>      <xsd:sequence/>
>    </xsd:restriction>
>   </xsd:complexContent>
>  </xsd:complexType>
> </xsd:element>
>
> Which provides an empty element with no attributes. Because of the use of
an
> anonymous type adding attributes is in fact impossible in this case, a
named
> type should probably be used instead.
>
> I don't *think* extension would actually be allowed as I believe it is
> impossible to extend the urType ( anyType ). However, I am checking this
and
> will confirm later.
>
> With respect to mixed content the 'mixed' attribute was chosen over a
> mixedContent element to allow construction of types like the following
>
> <complexType name='paragraph' mixed='true'>
>   <choice minOccurs='0' maxOccurs='1' >
>     <element name='b' type='string' />
>     <element name='i' type='string' />
>   </choice>
> </complexType>
>
> We didn't want people who just wanted to restrict the urType ( anyType )
to
> have to go to the full blown content model for complexType just to get
mixed
> content.
>
> Hope this helps,
>
> Martin Gudgin
>
> ----- Original Message -----
> From: <ramesh@e...>
> To: <xml-dev@x...>
> Sent: Saturday, September 30, 2000 12:30 AM
> Subject: Empty Complex Type; Mixed Content Type
>
>
> > Section 2.5.3 in the XML Schema Part 0: Primer describes how to define
an
> > empty complex type.
> >
> > The example uses restriction while adding a couple attributes to the
type.
> > Is that a typo? I expected to use extension in this case.
> >
> > I also found <xsd:complexType mixed="true"> a little jarring in the
> example
> > in section 2.5.2, because I was expecting <xsd:mixedContent> for
> consistency
> > with <xsd:simpleContent> and <xsd:complexContent>, but this may already
> have
> > been covered in earlier debates. If that's the case, please disregard
this
> > comment.
> >
> > Thanks for clarifying.


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.