OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: Derived by extension and restriction in XML schema

[ Lists Home | Date Index | Thread Index ]
  • From: ht@cogsci.ed.ac.uk (Henry S. Thompson)
  • To: "David Valera" <dvalera@pcl-hage.nl>
  • Date: 15 Jun 2000 12:17:45 +0100

"David Valera" <dvalera@pcl-hage.nl> writes:

> Hello,
> I asked this question a few days ago in comp.text.xml but I didnt get any
> answers. Maybe I will get more lucky here. Here is the problem I have:
> I have a complextype in an XML schema declared like this:
> 	<xsd:complexType name="HeaderType" content="elementOnly">
> 		<xsd:element name="messagekind" type="xsd:string"/>
> 		<xsd:element name="messageversion" type="xsd:string"/>
> 		<xsd:element name="Value" type="xsd:string" minOccurs="0" maxOccurs="3"/>
> 	</xsd:complexType>
> I have another complextype that is derived from this one. I need to add a
> few elements, and I need to restrict the 'value' element. Can I do
> something like this?
> <xsd:element name="SpecialHeader">
> 	<xsd:complexType base="HeaderType" derivedBy="extension">
> 		<xsd:element name="Value" type="xsd:string" minOccurs="3"/>
> 		<xsd:element name="HeaderText" type="xsd:string"/>
> 	</xsd:complexType>
> </xsd:element>
> I am adding a new element called HeaderText' and restricting the 'Value'
> element to appear at least and most 3 times.

No, you're adding two new elements -- you can't restrict and extend at 
the same time.

> Is this correct or should I do it this way:
> <xsd:complexType name="SpecialHeaderType" base="HeaderType"
> derivedBy="extension">
> 	<xsd:element name="HeaderText" type="xsd:string"/>
> </xsd:complexType>
> <xsd:element name="SpecialHeader">
> 	<xsd:complexType base="SpecialHeaderType" derivedBy="restriction">
> 		<xsd:element name="Value" type="xsd:string" minOccurs="3"/>
> 	</xsd:complexType>
> </xsd:element>

That should do it.

  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-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/

This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@xml.org&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS