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

Re: Help regarding an XML attribute.

  • From: Eddie Robertsson <eddie@a...>
  • To: Vance Christiaanse <cintech@t...>
  • Date: Mon, 17 Sep 2001 10:15:58 +1000

xsd simplecontent restriction
> I just meant "Do we all agree that the following is illegal according to the
> spec
>
> <xsd:complexType ...>
>    <xsd:complexContent>
>       <xsd:extension base="xsd:string">
>          <xsd:attribute .../>
>       </xsd:extension>
>    </xsd:complexContent>
> </xsd:complexType>
>
> and the following legal
>
> <xsd:complexType ...>
>    <xsd:simpleContent>       <!-- Change 1 of 2 -->
>       <xsd:extension base="xsd:string">
>          <xsd:attribute .../>
>       </xsd:extension>
>    </xsd:simpleContent>      <!-- Change 2 of 2 -->
> </xsd:complexType>
>
> since string is a simple type?"

Yes.

Cheers,
/Eddie

>
>
> Vance
>
> > -----Original Message-----
> > From: Eddie Robertsson [mailto:eddie@a...]
> > Sent: Tuesday, October 16, 2001 7:44 PM
> > To: Vance Christiaanse
> > Cc: Ronald Bourret; Wayne Steele; Huylanp@o...;
> > xml-dev@l...
> > Subject: Re:  Help regarding an XML attribute.
> >
> >
> > > > If the <complexContent> alternative is chosen, the type definition
> > > > ·resolved· to by the ·actual value· of the base [attribute] must be
> > > > a complex type definition;
> > >
> > > It now seems as though the definition earlier in this message is still
> > > incorrect and the following is correct:
> > >
> > > <xsd:complexType ...>
> > >    <xsd:simpleContent>       <!-- Change 1 of 2 -->
> > >       <xsd:extension base="xsd:string">
> > >          <xsd:attribute .../>
> > >       </xsd:extension>
> > >    </xsd:simpleContent>      <!-- Change 2 of 2 -->
> > > </xsd:complexType>
> > >
> > > We all agree now that "extension" is correct and "restriction" is not
> > > correct.
> > >
> > > Do we also agree that "simpleContent" is correct and
> > "complexContent" is not
> > > correct?
> >
> > Well, I guess it depends on the use case but if the resulting
> > type should have
> > simple content then you use xs:simpleContent (when you want to
> > extend a simple
> > type by adding an attribute as in the above case). On the other
> > hand if you want
> > the resulting type to be complex you use xs:complexType.
> > Priscilla gave the
> > following example in a previous thread:
> >
> > <xs:complexType name="base">
> >   <xs:sequence>
> >     <xs:element name="child"/>
> >   </xs:sequence>
> >   <xs:attribute name="attr1" type="xs:integer"/>
> > </xs:complexType>
> >
> > <xs:complexType name="derived">
> >   <xs:complexContent>
> >     <xs:restriction base="base">
> >       <xs:attribute name="attr1" type="xs:short" use="required"
> > default="1"/>
> >     </xs:restriction>
> >   </xs:complexContent>
> > </xs:complexType>
> >
> > Cheers,
> > /Eddie
> >
> > >
> > > Vance
> > >
> > > PS: I agree that both schemas below that XML Spy 4.0.1 accepted
> > are, indeed,
> > > illegal.
> > >
> > > > -----Original Message-----
> > > > From: Eddie Robertsson [mailto:eddie@a...]
> > > > Sent: Monday, October 15, 2001 11:35 PM
> > > > To: Vance Christiaanse
> > > > Cc: Ronald Bourret; Wayne Steele; Huylanp@o...;
> > > > xml-dev@l...
> > > > Subject: Re:  Help regarding an XML attribute.
> > > >
> > > >
> > > > > an attribute element is allowed
> > > > > within either a restriction element or an extension element that is
> > > > > within either a simpleContent element or a complexContent
> > > > element that is
> > > > > within a complexType element. (At least that's how I read it.)
> > > >
> > > > Yes, an attribute element is allowed within a restriction element
> > > > but _only_
> > > > if the type in the base attribute resolves to a complex type.
> > > > The spec [1] reads:
> > > >
> > > > "If the <simpleContent> alternative is chosen, the type
> > > > definition ·resolved·
> > > > to by the ·actual value· of the base [attribute] must be either a
> > > > complex type
> > > > definition whose {content type} is a simple type definition or,
> > > > only if the
> > > > <extension> alternative is also chosen, a simple type definition;"
> > > >
> > > > This says that the type resolved to by the base attribute can
> > only be a
> > > > simpleType if the extension alternative is chosen.
> > > >
> > > > > Both of the following are judged legal by XML Spy 4.0.1.
> > > > >
> > > > > In other words, I think my original schema is legal.
> > > >
> > > > I might be reading the spec wrong but I believe the schema below
> > > > is in error
> > > > and XML Spy is wrong.
> > > >
> > > > Cheers,
> > > > /Eddie
> > > >
> > > > [1]
> > > > http://www.w3.org/TR/xmlschema-1/#section-Constraints-on-XML-Repre
> > > > sentations-of-Complex-Type-Definitions
> > > >
> > > >
> > > >
> > > > > But I might agree that using simpleContent and extension is
> > probably the
> > > > > most intuitive way to write this.
> > > > >
> > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > > elementFormDefault="qualified" attributeFormDefault="unqualified">
> > > > > <xs:element name="myOuter">
> > > > >    <xs:complexType>
> > > > >       <xs:complexContent>
> > > > >          <xs:restriction base="xs:string">
> > > > >             <xs:attribute name="color" type="xs:string"/>
> > > > >          </xs:restriction>
> > > > >       </xs:complexContent>
> > > > >    </xs:complexType>
> > > > > </xs:element>
> > > > > </xs:schema>
> > > > >
> > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > > elementFormDefault="qualified" attributeFormDefault="unqualified">
> > > > > <xs:element name="myOuter">
> > > > >    <xs:complexType>
> > > > >       <xs:simpleContent>
> > > > >          <xs:restriction base="xs:string">
> > > > >             <xs:attribute name="color" type="xs:string"/>
> > > > >          </xs:restriction>
> > > > >       </xs:simpleContent>
> > > > >    </xs:complexType>
> > > > > </xs:element>
> > > > > </xs:schema>
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Eddie Robertsson [mailto:eddie@a...]
> > > > > > Sent: Monday, October 15, 2001 7:57 PM
> > > > > > To: Vance Christiaanse
> > > > > > Cc: Ronald Bourret; Wayne Steele; Huylanp@o...;
> > > > > > xml-dev@l...
> > > > > > Subject: Re:  Help regarding an XML attribute.
> > > > > >
> > > > > >
> > > > > > > <xsd:complexType ...>
> > > > > > >    <xsd:complexContent>
> > > > > > >       <xsd:restriction base="xsd:string">
> > > > > > >          <xsd:attribute .../>
> > > > > > >       </xsd:restriction>
> > > > > > >    </xsd:complexContent>
> > > > > > > </xsd:complexType>
> > > > > >
> > > > > > Not exactly. To create a text only content complex type with
> > > > one or more
> > > > > > attributes you must _extend_ a simple type. So, the
> > correct definition
> > > > > > would be:
> > > > > >
> > > > > > <xsd:complexType ...>
> > > > > >    <xsd:complexContent>
> > > > > >       <xsd:extension base="xsd:string">
> > > > > >          <xsd:attribute .../>
> > > > > >       </xsd:extension>
> > > > > >    </xsd:complexContent>
> > > > > > </xsd:complexType>
> > > > > >
> > > > > > Cheers,
> > > > > > /Eddie
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: Ronald Bourret [mailto:rpbourret@r...]
> > > > > > > > Sent: Monday, October 15, 2001 2:20 PM
> > > > > > > > To: Wayne Steele
> > > > > > > > Cc: Huylanp@O...; xml-dev@l...
> > > > > > > > Subject: Re:  Help regarding an XML attribute.
> > > > > > > >
> > > > > > > >
> > > > > > > > Wayne Steele wrote:
> > > > > > > > >
> > > > > > > > > >From: Huy-Lan Phan <Huylanp@O...>
> > > > > > > > > ... I think only a complex element can have attributes ...
> > > > > > > > >
> > > > > > > > > You are correct. Only a complex element can have attributes.
> > > > > > > >
> > > > > > > > But don't forget that a complex type can have simple content.
> > > > > > > >
> > > > > > > > <complexType>
> > > > > > > >    <simpleContent>
> > > > > > > >       <restriction base="xsd:string" />
> > > > > > > >    </simpleContent>
> > > > > > > >    <attribute>...</attribute>
> > > > > > > >    ...
> > > > > > > > </complexType>
> > > > > > > >
> > > > > > > > -- Ron
> > > > > > > >
> > > > > > > >
> > -----------------------------------------------------------------
> > > > > > > > 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 elist 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 elist 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 elist 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 elist 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 elist 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.