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

Re: RE : Re: RE : Text or tags choice with


xs complextype mixed true
<Quote>
practically, from the instances creator point of view (the one that
write an instance), is it differing so much with the following ?

<time-complex><hour>14</hour><min>59</min></time>

<time-simple>14:59</time>
</Quote>

Yes it is, and necessarily so. The xsi:type value is needed so that the
schema processor knows which of the types is being used at runtime.

Kind Regards,
Joe Chiusano
Booz | Allen | Hamilton


GARNIER Pierre wrote:
> 
> Here are the two instances that you give (simplified):
> 
> <time xsi:type="complexTime"><hour>14</hour><min>59</min></time>
> 
> <time xsi:type="simpleTime">14:59</time>
> 
> I don't want to be embarrassing, but, practically, from the instances
> creator point of view (the one that write an instance), is it differing so
> much with the following ?
> 
> <time-complex><hour>14</hour><min>59</min></time>
> 
> <time-simple>14:59</time>
> 
> Thanks a lot everybody for your assistance.
> 
> -----Message d'origine-----
> De : Dare Obasanjo [mailto:dareo@m...]
> Envoyé : mardi 9 septembre 2003 15:37
> À : Chiusano Joseph
> Cc : GARNIER Pierre; xml-dev@l...
> Objet : RE:  Re: RE :  Text or tags choice with XSD
> 
> Actually I was wrong. I've never thought about solving the problem using
> xsi:type before. Using xsi:type makes it possible, schema and instances
> follow
> 
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>   elementFormDefault="qualified" targetNamespace="urn:foo"
> xmlns:foo="urn:foo">
> 
>    <xs:element name="time" type="foo:abstractType" />
> 
>    <xs:complexType name="abstractType" abstract="true" mixed="true">
>     <xs:sequence>
>       <xs:element name="placeholder" minOccurs="0" />
>     </xs:sequence>
>    </xs:complexType>
> 
>    <xs:complexType name="simpleTime" mixed="true">
>     <xs:complexContent>
>      <xs:restriction base="foo:abstractType">
>       <xs:sequence>
>        <xs:element name="placeholder" maxOccurs="0" />
>       </xs:sequence>
>      </xs:restriction>
>     </xs:complexContent>
>    </xs:complexType>
> 
>     <xs:complexType name="removeMixed" mixed="false" abstract="true">
>     <xs:complexContent>
>      <xs:restriction base="foo:simpleTime" />
>     </xs:complexContent>
>    </xs:complexType>
> 
>    <xs:complexType name="complexTime">
>     <xs:complexContent>
>      <xs:extension base="foo:removeMixed">
>       <xs:sequence>
>        <xs:element name="hour" type="xs:int" />
>        <xs:element name="min" type="xs:int" />
>       </xs:sequence>
>      </xs:extension>
>     </xs:complexContent>
>    </xs:complexType>
> 
> </xs:schema>
> 
> 
> <time xmlns="urn:foo" xmlns:foo="urn:foo"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:type="foo:complexTime"><hour>14</hour><min>59</min></time>
> 
> <time xmlns="urn:foo" xmlns:foo="urn:foo"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:type="foo:simpleTime">14:59</time>
> 
> 
> ________________________________
> 
> From: Chiusano Joseph [mailto:chiusano_joseph@b...]
> Sent: Tue 9/9/2003 7:14 AM
> To: Dare Obasanjo
> Cc: GARNIER Pierre; xml-dev@l...
> Subject: Re:  Re: RE :  Text or tags choice with XSD
> 
> <Quote>
> such content models are not describable with W3C XML Schema. </Quote>
> 
> I see...the original example below cannot have a base type from which a
> derived type is created, because of the how the 2 content models are
> represented. Is that what you're driving at?
> 
> Kind Regards,
> Joe Chiusano
> Booz | Allen | Hamilton
> 
> Dare Obasanjo wrote:
> >
> > That would be a neat trick. Do you have an example of what the schema
> > definition would be? I've always been of the impression that such
> > content models are not describable with W3C XML Schema.
> >
> >
> >
> > ________________________________
> >
> > From: Chiusano Joseph [mailto:chiusano_joseph@b...]
> > Sent: Tue 9/9/2003 6:44 AM
> > To: GARNIER Pierre
> > Cc: 'xml-dev@l...'
> > Subject:  Re: RE :  Text or tags choice with XSD
> >
> > Oops - I forgot about that. Then you should probably use abstract
> > types (see section 4.7 Abstract Elements and Types of the Schema
> > Primer) and use xsi:type in your instance document to define which
> > type is being used at runtime.
> >
> > Kind Regards,
> > Joe Chiusano
> > Booz | Allen | Hamilton
> >
> > GARNIER Pierre wrote:
> > >
> > > No, union are not usable within complex types.
> > >
> > > > Pierre,
> > > >
> > > > This can be done with Union types [1].
> > > >
> > > > Kind Regards,
> > > > Joe Chiusano
> > > > Booz | Allen | Hamilton
> > > >
> > > > [1]
> > > > http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/primer.html#Uni
> > > > onDt
> > > >
> > > > GARNIER Pierre wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > Here are two <time> elements differing only in there content :
> > > > >
> > > > > 1)
> > > > > <doc>
> > > > >   <time>14:09<time>
> > > > > </doc>
> > > > >
> > > > > 2)
> > > > > <doc>
> > > > >   <time><hour>14</hour><min>09</min></time>
> > > > > </doc>
> > > > >
> > > > > In an XSD schema, how to indicate that the <time> element can
> > > > > contain text and only text or <hour> tag followed by <min> tag?
> > > > >
> > > > > I tried with a choice group containing two <time> elements with
> > > > > different types but it doesn't work : it is not possible to have
> > > > > two elements with the same name.
> > > > >
> > > > > Thanks.
> > > > > Pierre.
> > > > >
> > > > > ----------------------------------------------------------------
> > > > > -
> > > > > 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>
begin:vcard 
n:Chiusano;Joseph
tel;work:(703) 902-6923
x-mozilla-html:FALSE
url:www.bah.com
org:Booz | Allen | Hamilton;IT Digital Strategies Team
adr:;;8283 Greensboro Drive;McLean;VA;22012;
version:2.1
email;internet:chiusano_joseph@b...
title:Senior Consultant
fn:Joseph M. Chiusano
end:vcard

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.