Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > In Schema, how to say "If one element exist, another element must exist"?

Reply
Thread Tools

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

 
 
Y.S.
Guest
Posts: n/a
 
      09-16-2003
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
 
Reply With Quote
 
 
 
 
Thomas Scheffler
Guest
Posts: n/a
 
      09-17-2003
Y.S. schrieb:
> 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

 
Reply With Quote
 
 
 
 
Puff Addison
Guest
Posts: n/a
 
      09-17-2003
Y.S. wrote:

>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>

--
J. D. Addison
email http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
strajan
Guest
Posts: n/a
 
      09-17-2003
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.
"Y.S." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
You Say “Fragmentation”, I Say “Differentiation” Lawrence D'Oliveiro NZ Computing 2 10-06-2010 04:44 AM
Move value from one form element to another, hidden element viaJavaScript OccasionalFlyer Javascript 6 07-29-2009 03:33 AM
You say SIM, I say SEM Anon Computer Security 1 03-18-2006 01:49 PM
Onchange of dropdownlist say "country" loaded,it must load all "states" for that country in another drop downlist. S.Guhananth ASP .Net 1 04-30-2005 12:01 PM
per the active schema, the element <BR> must be included within a parent element MSNews ASP .Net 1 04-22-2004 04:45 PM



Advertisments