Re: error in specifications?

Forge <forge@neonics.com> writes:

> Hi there,
> 
> I checked the xml specs and it says:
> 
> complexType 
>   abstract = boolean : false
>   block = (#all | List of (extension | restriction)) 
>   final = (#all | List of (extension | restriction)) 
>   id = ID 
>   mixed = boolean : false
>   name = NCName 
>   {any attributes with non-schema namespace . . .}>
>   Content: (annotation?, (simpleContent | complexContent | ((group | all |
> choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))
> </complexType>
> 
> 
> Which means to me that the following is valid:
> 
> <xsd:complexType name="bla">
>   <xsd:simpleContent>
>     <xsd:restriction ....>
>   </xsd:simpleContent>
>   <xsd:attribute name="..."/>
> </xsd:complexType>
> 
> However, XMLSpy does not think so.. 

You've misread the parentheses:
 
  Content: (annotation?, 
            (simpleContent  | 
             complexContent | 
             ((group  | 
               all    |
               choice |
               sequence)?,
              ((attribute | 
                attributeGroup)*, 
               anyAttribute?))))
I.e. once you choose <simpleContent> you're done, you can't have
<attribute> later.


> Then I found this example:
> 
> <xs:complexType name="length1">
>  <xs:simpleContent>
>   <xs:extension base="xs:non-negative-integer">
>    <xs:attribute name="unit" type="xs:NMTOKEN"/>
>   </xs:extension>
>  </xs:simpleContent>
> </xs:complexType>
> 
> 
> Is XMLSpy wrong?

Note the <attribute> is _inside_ the <extension>.

> Then:
> 
> I just wish to declare a tag like  <blah blah="blah">blah</blah>
> 
> This is not possible with an anonymous complexType definition. How come?
> 
> What I would like to do is:
> 
> <element name="blah" type="xsd:string">
>   <complexType>
>     <xsd:attribute ...>
>   </complexType>
> </element>
> 
> but this is not possible if element is not below the root node (haven't
> tested it when it's below the root node, however..)
> 
> Any clarifications on this?

 <xs:element name="blah">
  <xs:complexType>
   <xs:simpleContent>
     <xs:extension base="xs:string">
      <xs:attribute name="blah"/>
     </xs:extension>
    </xs:simpleContent>
   </xs:complexType>
 </xs:element>

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Wednesday, 28 March 2001 11:00:25 UTC