In Schema, how to say "If one element exist, another element must exist"?

Y

Y.S.

Hello All,

I have the following schema:
....
<xs:element name="data_type_id" type="xs:unsignedShort" />
<xs:element name="data_value" type="xs:anyType" />
....

What I want to do is to specify that "If 'data_value' element exists,
'data_type_id' element MUST exist".

How do I do that?

Thanks very much
 
T

Thomas Scheffler

Y.S. said:
Hello All,

I have the following schema:
...
<xs:element name="data_type_id" type="xs:unsignedShort" />
<xs:element name="data_value" type="xs:anyType" />
...

What I want to do is to specify that "If 'data_value' element exists,
'data_type_id' element MUST exist".

How do I do that?

Thanks very much

Hi,

you should consider to embed data-value inside data_type_id either by
attribute
<data_type_id value="somewhat"/>
or by element
<data_type_id>
<data_value/>
</data_type_id>

That's wy xml is structured. I cannot imagine that these kind of checks
are possible with xml schemas but of cause I maybe wrong....

Hope I could help you

Thomas Scheffler
 
P

Puff Addison

Y.S. said:
Hello All,

I have the following schema:
...
<xs:element name="data_type_id" type="xs:unsignedShort" />
<xs:element name="data_value" type="xs:anyType" />
...

What I want to do is to specify that "If 'data_value' element exists,
'data_type_id' element MUST exist".

How do I do that?

Thanks very much
Use <sequence>
<xs:sequence minoccurs="0">
<xs:element name="data_type_id" type="xs:unsignedShort" />
<xs:element name="data_value" type="xs:anyType" />
</xs:sequence>
 
S

strajan

Include both the elements within a sequence like the following:
=========
<xs:sequence minOccurs="0" maxOccurs="1">
<xs:element name="data_type_id" type="xs:unsignedShort" />
<xs:element name="data_value" type="xs:anyType" />
</xs:sequence>
==========

Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top