Re: attribute and restriction under same roof

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 UTC