Jump to content

Help : Elements with EITHER child elements, or simple contents


Kahor
 Share

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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...