473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Problem defining an XSD to validate for overlapping ranges

Hi

I have a problem to create an XSD that prevents overlapping ranges.

Sample XML:

<root>
<element LowerLimit="1" UpperLimit="50000">
.....
</element>
<element LowerLimit="50001" UpperLimit="250000">
.....
</element>
<element LowerLimit="250001" UpperLimit="500000">
.....
</element>
......
</root>

<element> is always of the same structure
<root> has minOccurs="1" and maxOccurs="unbounded"

range1 1 to 50000
range2 50001 to 250000
range3 250001 to 500000

Is it possible to create a schema that throws a validation error when ranges
overlap like in the following sample:

<root>
<element LowerLimit="1" UpperLimit="50000">
.....
</element>
<element LowerLimit="25000" UpperLimit="40000">
.....
</element>
<element LowerLimit="40001" UpperLimit="500000">
.....
</element>
......
</root>
Nov 12 '05 #1
1 1666
"Jim Di Griz" <s_*****@hotmail.com> wrote in message news:OC**************@TK2MSFTNGP11.phx.gbl...
Is it possible to create a schema that throws a validation error when ranges
overlap like in the following sample:

<root>
<element LowerLimit="1" UpperLimit="50000">
.....
</element>
<element LowerLimit="25000" UpperLimit="40000">
.....

: :

No. XML Schema is very limited in what sort of validations it can perform
that are external to an element. It's very good at validating everything about
an element: it's data type, required and optional particles, it's content model,
the regexp patterns of it's text. Once the validation of an element or attribute
comes to the question of basing the "is valid?" question on content _elsewhere_
in the XML document, XML Schema really starts to breakdown.

XML Schema has some capabilities when it comes to ensuring referential
integrity between elements, that means you can require some attribute (as
if it were a foreign key) of one element to match a "primary key" existing
elsewhere in the instance document. The logic, however, required to perform
range validations are outside of it's scope.

You might consider an alternative schema definition language, like RELAX NG
or Schematron. Otherwise, I'd perform a validation of this nature programmatically
in C#/VB.NET with DOM code and XmlDocument, or it's also probably possible
in XSLT (not ideal, IMO, but possible).
Derek Harmon
Nov 12 '05 #2

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

Similar topics

11
by: Max M | last post by:
I am writing a "find-free-time" function for a calendar. There are a lot of time spans with start end times, some overlapping, some not. To find the free time spans, I first need to convert the...
3
by: Phil Sandler | last post by:
All, I have a table with start and end dates/times in it, and would like to be able to calculate the number of hours represented, accounting for overlapping records. Note that I am looking...
13
by: Reuben Chew | last post by:
It seems that due to XP SP2's MIME type restrictions, when using Internet Explorer 6 SP2 to validate documents, it will spit out this error: ----------------------------------- Sorry, I am unable...
4
by: Simon Elliott | last post by:
Is there an equivalent of std::copy which works on STL containers for overlapping ranges? -- Simon Elliott http://www.ctsn.co.uk
2
by: Chesne | last post by:
I have a table with and which are in an accommodation db. I would like to be able to determine how many days are occupied for a particular month using the two fields as per above. By adding the ...
4
by: Wysiwyg | last post by:
I need to validate a form to ensure that all of the fields add up correctly. I can't do this while the user is entering data since validation needs to be done after the entry is completed. What's...
12
by: Adam Hartshorne | last post by:
Hi All, I was wondering if somebody could post a few lines of code which would produce random colors, which will be used in defining different regions on a mesh. So in addition to having n...
4
by: Mohsen | last post by:
Dear all, I have used pointer in my program and I have a problem with shuffling the values. The code is like: .. .. .. for(i=0;i<S;++i) {
7
by: Breal | last post by:
I have a list that looks like the following I would like to be able to determine which of these overlap each other. So, in this case, tuple 1 overlaps with tuples 2 and 3. Tuple 2 overlaps...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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,...

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.