W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2011

Self reference in an element

From: Avinash Nagabhushan <avinash.sit@gmail.com>
Date: Tue, 12 Jul 2011 11:50:42 +0530
Message-ID: <CAH+W65z1+XCvQvWEfGSNpyA6W6KEmZ78892adJmFzYSSTi4j1w@mail.gmail.com>
To: David.Hirtle@nrc-cnrc.gc.ca, xmlschema-dev@w3.org
Hi Sir,

       I am writing an schema for the following structure:

Organization
    dept +
        @num
        name
        total_emp
        dept +
where dept elements are nested within another dept element, but all
departments are under organization.


My Schema is:


<xs:schema xmlns:ns1="http://www.ns1.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ns1.com">
	<xs:element name="Organization">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="Department" maxOccurs="unbounded">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Name"/>
							<xs:element name="TotalEmp"/>
							<xs:element ref="ns1:Department" minOccurs="0" maxOccurs="unbounded"/>
						</xs:sequence>
						<xs:attribute name="num" type="xs:string"/>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
</xs:schema>


There is a validation error saying "ns1:Department" is not a QName and
cannot find declaration for the same. Is there something wrong in my
definition?


Can you please let me know whether it is a correct approach or wrong?


Thanks,

Avinash K N
Received on Tuesday, 12 July 2011 10:00:16 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:59 UTC