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

attribute and restriction under same roof

From: Venkat Raghavan <venkat@okena.com>
Date: Fri, 28 Mar 2003 17:19:40 -0500
To: xmlschema-dev@w3.org
Message-ID: <BGEFJNOIEEOAKAJFMIPCKENDCBAA.venkat@okena.com>


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"/>

I have tried playing with all simpleType, complexType, simpleContent and
complexContent and cant seem to get it right. XMLSpy complains about one
thing or another. Whats a good element type under which xsd:restriction and
xsd:attribute can live together in harmony ?

I have even tried adding xsd:attribute under xsd:restriction. Priscilla
Walmsley's Definitive XML Schema (Appendix A, pg 486) says that restriction
can be a parent to attribute for a local attribute definition. But XML Spy
complains about it and says its unexpected.

I need your suggestions.

I want to be able to do this
<RuleType RuleTypeNum=4>Buffer overflow</RuleType>

Thanks,

Venkat
Received on Friday, 28 March 2003 17:13:42 GMT

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