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

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xml-dev] 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-Representations-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@allette.com.au]
> > Sent: Monday, October 15, 2001 7:57 PM
> > To: Vance Christiaanse
> > Cc: Ronald Bourret; Wayne Steele; Huylanp@oceanwide.com;
> > xml-dev@lists.xml.org
> > Subject: Re: [xml-dev] 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@rpbourret.com]
> > > > Sent: Monday, October 15, 2001 2:20 PM
> > > > To: Wayne Steele
> > > > Cc: Huylanp@Oceanwide.com; xml-dev@lists.xml.org
> > > > Subject: Re: [xml-dev] Help regarding an XML attribute.
> > > >
> > > >
> > > > Wayne Steele wrote:
> > > > >
> > > > > >From: Huy-Lan Phan <Huylanp@Oceanwide.com>
> > > > > ... 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>
> >
> >