W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2003

Re: attribute and restriction under same roof

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 02 Apr 2003 09:07:47 +0100
To: Venkat Raghavan <venkat@okena.com>
Cc: xmlschema-dev@w3.org
Message-ID: <f5b65px5nl8.fsf@erasmus.inf.ed.ac.uk>

Venkat Raghavan <venkat@okena.com> writes:

> Hi all,
> I have the following element inside a xsd:sequence.
> 
> <xsd:element name="RuleType">
> <xsd:annotation>
> 	<xsd:documentation>The type of the rule that caused the
> event.</xsd:documentation>
> </xsd:annotation>
> <xsd:simpleType>
> 	<xsd:restriction base="xsd:string">
> 		<xsd:enumeration value="Agent service control"/>
> 		<xsd:enumeration value="Application analyzer"/>
> 		<xsd:enumeration value="Application control"/>
> 		<xsd:enumeration value="Buffer overflow"/>
> 	</xsd:restriction>
> </xsd:simpleType>
> </xsd:element>
> 
> I would like to add an attribute to this element as shown below
> 
> <xsd:attribute name="RuleTypeNum" type="xsd:integer" use="required"/>
> 

This can only be done in two steps.  Name the simple type above, then
use extension to add the attribute:

<xsd:simpleType name="RTV">
	<xsd:restriction base="xsd:string">
		<xsd:enumeration value="Agent service control"/>
		<xsd:enumeration value="Application analyzer"/>
		<xsd:enumeration value="Application control"/>
		<xsd:enumeration value="Buffer overflow"/>
	</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="RTT">
 <xsd:simpleContent>
  <xsd:extension base="RTV">
   <xsd:attribute name="RuleTypeNum" type="xsd:integer" use="required"/>
  </xsd:extension>
 </xsd:simpleContent>
</xsd:complexType>

<xsd:element name="RuleType" type="RTT">
 <xsd:annotation>
  <xsd:documentation>The type of the rule that caused the
                     event.</xsd:documentation>
 </xsd:annotation>
</xsd:element>

ht
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                      Half-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/
 [mail really from me _always_ has this .sig -- mail without it is forged spam]
Received on Wednesday, 2 April 2003 03:07:50 GMT

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