W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2001

Re: Attribute as well as textvalue

From: <Noah_Mendelsohn@lotus.com>
Date: Thu, 11 Oct 2001 16:56:30 -0400
To: "Kuberean, Venkatesan (Cognizant)" <Venkatk@chn.cognizant.com>
Cc: xmlschema-dev@w3.org
Message-ID: <OFC35D669A.943EC3CC-ON85256AE2.0073469A@lotus.com>
The answers to many such questions are in the schema primer.  In this 
case, you are looking to get a complex type (can have attributes and 
element content) from a simple type (your author is basically a string). 
The primer covers this at [1].

Roughly, you would do something like:

<xsd:element name="author">
  <xsd:complexType>
   <xsd:simpleContent>
    <xsd:extension base="xsd:string">
     <!-- following defines attribute named YourAttribute
          with a type of xsd:string...define as many
          attributes as you need. --> 
     <xsd:attribute name="YourAttribute" type="xsd:string"/>
    </xsd:extension>
   </xsd:simpleContent>
  </xsd:complexType>
 </xsd:element>

Hope this helps.   I do suggest you read the primer, as it  covers many 
questions that you will encounter as a new user of schemas.

[1] http://www.w3.org/TR/xmlschema-0/#complexTfromSimpleT

------------------------------------------------------------------------
Noah Mendelsohn                                    Voice: 1-617-693-4036
Lotus Development Corp.                            Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------------
Received on Thursday, 11 October 2001 17:05:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:24 GMT