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

Re: XSD Prob

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>
Message-ID: <f5bsmjgztys.fsf@erasmus.inf.ed.ac.uk>

<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 xsi:type="b">
  <b1>test b1</b1>
  <b2>test b2</b2>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 <xs:element name="a" type="general"/>
 <xs:complexType name="general" abstract="true">
   <xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
 <xs:complexType name="b">
   <xs:restriction base="general">
     <xs:element name="b1"/>
     <xs:element name="b2"/>
 <xs:complexType name="c">
   <xs:restriction base="general">
     <xs:element name="c1"/>
     <xs:element name="c2"/>

  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

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