473,804 Members | 3,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Schema question regarding some mandatory/some optional values

Hi,
I have XML like

<SomeElement>
<Value>5</Value>
<Value>3</Value>
<Value>7</Value>
</SomeElement>

I want to define the schema to say that the <Value>s must contain at least
one of a number of known values, and may contain some other <Value>s. For
example, if the known <Value>s were 3 and 5 then the above is valid. Also,

<SomeElement>
<Value>5</Value>
<Value>1</Value>
</SomeElement>

AND

<SomeElement>
<Value>3<Valu e>
</SomeElement>

are valid because they contain one of (3 and 5). But

<SomeElement>
<Value>8</Value>
</SomeElement>

is not valid. I've tried defining this using xs:all and enumerations but
with no luck. All suggestions gratefully received.

Thanks,
Piers
Jul 20 '05 #1
2 1399
One suggestion is to change the
<Value>5</Value>
to a
<Value5>...</Value5>
That way you can have multiple values i.e. each value is equal to an element
and hence write a DTD/Schema that makes it conform to your rules defined
below...
"Piers Chivers" <Piers.Chivers@ _no_spam_.btint ernet.com> wrote in message
news:c1******** **@hercules.bti nternet.com...
Hi,
I have XML like

<SomeElement>
<Value>5</Value>
<Value>3</Value>
<Value>7</Value>
</SomeElement>

I want to define the schema to say that the <Value>s must contain at least
one of a number of known values, and may contain some other <Value>s. For
example, if the known <Value>s were 3 and 5 then the above is valid. Also,
<SomeElement>
<Value>5</Value>
<Value>1</Value>
</SomeElement>

AND

<SomeElement>
<Value>3<Valu e>
</SomeElement>

are valid because they contain one of (3 and 5). But

<SomeElement>
<Value>8</Value>
</SomeElement>

is not valid. I've tried defining this using xs:all and enumerations but
with no luck. All suggestions gratefully received.

Thanks,
Piers

Jul 20 '05 #2
I don't think this can work. It doesn't feel instinctively right (not that
my XML instincts are particularly good!). The mian problem though is that I
don't know what all of the possible values are. I might have a Value1002 or
Value27649 etc. How do I represent this in a schema?

I'm surprised this is so difficult. I would have thought that a schema that
said "Many values allowed but at least one of them must be blahblah" isn't
such an unusual request??

Piers
"Martin SChukrazy" <pr****@hotmail .com> wrote in message
news:40******** **************@ news.rcn.com...
One suggestion is to change the
<Value>5</Value>
to a
<Value5>...</Value5>
That way you can have multiple values i.e. each value is equal to an element and hence write a DTD/Schema that makes it conform to your rules defined
below...
"Piers Chivers" <Piers.Chivers@ _no_spam_.btint ernet.com> wrote in message
news:c1******** **@hercules.bti nternet.com...
Hi,
I have XML like

<SomeElement>
<Value>5</Value>
<Value>3</Value>
<Value>7</Value>
</SomeElement>

I want to define the schema to say that the <Value>s must contain at least one of a number of known values, and may contain some other <Value>s. For example, if the known <Value>s were 3 and 5 then the above is valid.

Also,

<SomeElement>
<Value>5</Value>
<Value>1</Value>
</SomeElement>

AND

<SomeElement>
<Value>3<Valu e>
</SomeElement>

are valid because they contain one of (3 and 5). But

<SomeElement>
<Value>8</Value>
</SomeElement>

is not valid. I've tried defining this using xs:all and enumerations but with no luck. All suggestions gratefully received.

Thanks,
Piers


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1854
by: Alex Sab | last post by:
Hi, I am having trouble describing in a schema that elements can be mandatory in one part and not mandatory in another part of the xml document. Here is a sample xml file <Model:Templates> <Node:Template Node:nodeId="nodeID"> <Node:Name Node:Comment="">Name</Node:Name> <Node:Name2 Node:Comment="">Name</Node:Name2> ...
1
1422
by: Maxim | last post by:
If there is a document like this: <Configurations> <Configuration default="true"> ... </Configuration> <Configuration> ...
2
1192
by: Th.-Fischer | last post by:
hi, i have this xml structure <users> <user id="root"/> <!-- mandatory! --> <user id="a"/> <!-- optional --> <user id="b"/> <!-- optional --> <user id="c"/> <!-- optional --> </users> what i like to define in schema is, that users
0
1957
by: Sahmiac | last post by:
Hello Everyone, I'm sure this question has been asked a million times, but I'm going crazy trying to get my xml validation to work. I've spent the day reading msdn, the dot net documentation and samples found on the web, and I'm still having no luck. Basically, the file always loads without error, even though it shouldn't be valid. Here are my various files, any help is greatly appreciated. There are some comments inline. thanks so...
1
4723
by: Le Tubs | last post by:
Hi I am wondering if anybody has come accross this problem before, basically I have to validate a xml schema (not the data, this is done at a later stage). The only problem is that there are Mandatory fields, and Optional fields. Thus I don't think a DTD can be used (as a valid xml file can just have the mandatory fields). I have a designed a small validation engine in perl which I'm about to start to code up, but thought I might check...
9
3023
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13> <binaryobject3></binaryobject3>
4
2710
by: Eric | last post by:
Attached is an example of my question. Note the "values" attribute is optional. Also the <valuesub-element is optional. Here, the XML can contain, 1 or both or neither. I would like to allow EITHER the "values" attribute or <valuesub-elements - but not both. I tried using a <choicewith two element definitions for "characteristic" with different content, but this is clearly not allowed in XSD. Does anyone have an answer? Thanks.
0
2635
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of the particle of the base this xsd file is valid as per w3c standard i am also providing error in detail and geometry.xsd file geometry.xsd <?xml version="1.0" encoding="UTF-8"?> <schema targetNamespace="http://www.opengis.net/gml"...
2
2152
by: BD | last post by:
I'm working with a data model which is managed in the AllFusion ERwin tool. Within the modeler, some of the FK relationships are 'non-mandatory' - which is to say that for a given child value, a parent value is optional. This is different from an optional child key, where the child table allows null values - in this case it's the relation itself that is optional. Strikes me as rather contrary to the principles of RI...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10076
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.