|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Derived by extension and restriction in XML schema
"David Valera" <dvalera@p...> 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.
ht
--
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@c...
URL: http://www.ltg.ed.ac.uk/~ht/
***************************************************************************
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








