[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Derived by extension and restriction in XML schema

  • From: "David Valera" <dvalera@p...>
  • To: <xml-dev@x...>
  • Date: Thu, 15 Jun 2000 09:51:58 +0200

xml schema derivedby
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.

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>

Or maybe both methods are wrong :-)

Thanks for any help on this.


--
David Valera


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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.