Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - simple attribute question [Thread Next] Re: simple attribute questionTo: Rob Harrington <robot252@-----.---> Date: 8/11/2004 10:29:00 PM
Hi Rob,
> In my schema definition, I simply want to express this
> xml:
>
> <item sometext="attributeText">9899</item>
>
> where 9899 is a positive integer.
<item> is an element with attributes whose content is a simple value.
Since it has attributes, it *must* have a complex type:
<xs:element name="item">
<xs:complexType>
...
</xs:complexType>
</xs:element>
but since it contains only text, it has simple content:
<xs:element name="item">
<xs:complexType>
<xs:simpleContent>
...
</xs:simpleContent>
</xs:complexType>
</xs:element>
If the element was of a simple type, it would just have content, no
attributes. To create a type with attributes and simple content, you
have to *extend* the simple type to add the attribute:
<xs:element name="item">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:long">
<xs:attribute name="sometext" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
From robot252@y... Wed Aug 11 20:59:08 2004
Received: from dr-nick.w3.org ([ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
