Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: simple attribute question

From: Jeni Tennison <jeni@------------.--->
To: 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 ([


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent