- From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
- Date: Fri, 19 Dec 2003 15:51:39 +0000
- To: <davuluri.hyma@wipro.com>
- Cc: <xmlschema-dev@w3.org>
<davuluri.hyma@wipro.com> writes: > Hi all, > Is there a way to write a xsd which validates a xml which is having > something like this. > > <a b="c"> > <c1>test c1</c1> > <c2>test c2</c2> > </a> If you are in a position to spell 'b' a different way, namely 'xsi:type', then this is easy: <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <a xsi:type="c"> <c1>test c1</c1> <c2>test c2</c2> </a> <a xsi:type="b"> <b1>test b1</b1> <b2>test b2</b2> </a> </root> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org/xsit" targetNamespace="http://www.example.org/xsit" elementFormDefault="qualified"> <xs:element name="a" type="general"/> <xs:complexType name="general" abstract="true"> <xs:sequence> <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/> </xs:sequence> </xs:complexType> <xs:complexType name="b"> <xs:complexContent> <xs:restriction base="general"> <xs:sequence> <xs:element name="b1"/> <xs:element name="b2"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="c"> <xs:complexContent> <xs:restriction base="general"> <xs:sequence> <xs:element name="c1"/> <xs:element name="c2"/> </xs:sequence> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:schema> 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 Friday, 19 December 2003 10:51:44 UTC