Jump to content

Help : Elements with EITHER child elements, or simple contents

Recommended Posts

------- Feel free to delete --------Hello everyone, me againIn my xml file, I have an element that either have chield elements, much like

<header name="smthing">	<description>descr</description>	<return>...</return>	...</header>

which I describe this way in my xml schema

<xs:element name="header">		<xs:complexType>			<xs:sequence>				<xs:element ref="description" minOccurs="0"/>				<xs:element ref="return" minOccurs="0"/>								...			</xs:sequence>			<xs:attribute name="name" type="xs:string"/>		</xs:complexType></xs:element>

or have simple content, much like :

<header>Not in use</header>

How can I describe this element with the same xml schema element that will still be valide in the two cases ?Using two local declaration of header does not work because they appear (either one or another) in the same element.I was thinking of using the <xs:simpleContent> but this doesn't seem to work, maybe two xml schema declaration of the header element with a (or/|) in between but I don't know how this work either.Can anyone help ?ThxEdit : the more I think about it, the more I figure it looks like invalid xml, it probably shouldn't be like that, but I am still interested in the answer if anyone's got it.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...