473,386 Members | 1,799 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,386 software developers and data experts.

Schema maxInclusive puzzle

I don't think what I want to do with maxInclusive is possible, but
I thought I'd ask others what they thought. As an example,
here is some very simple XML:

<birthday_cake>
<max_pieces>8</max_pieces>
<serving name="Joe">
<pieces>2</pieces>
</serving>
<serving name="Jane">
<pieces>1</pieces>
</serving>
</birthday_cake>

Is it possible to write a Schema rule to ensure that the maxInclusive
restriction
for <pieces> is equal to the value of <max_pieces>? In other words,
to ensure that no serving contains more pieces than the max_pieces for
the birthday_cake.

Now for the real stretch, is it possible to write a Schema rule to ensure
that the total of all <pieces> under <birthday_cake> is less-than or
equal-to the value of <max_pieces> for <birthday_cake>?

--
Don Adams
Jul 20 '05 #1
1 1800
"Don Adams" <dg*@sgi.com> wrote in message news:c1*************@fido.engr.sgi.com...
I don't think what I want to do with maxInclusive is possible, but
I thought I'd ask others what they thought.
I agree that it is not possible in XML Schema.

XML Schema defines the structure of an XML instance
document, but it is incapable of validating the content of
structural members against the content of _other_
structural members (you can use enumerations and
regular expression patterns to validate the content of
the structural member currently being validated; that's
about it.)

: : <birthday_cake>
<max_pieces>8</max_pieces>
<serving name="Joe">
<pieces>2</pieces>
</serving>
<serving name="Jane">
<pieces>1</pieces>
</serving>
</birthday_cake>

Is it possible to write a Schema rule to ensure that the maxInclusive
restriction for <pieces> is equal to the value of <max_pieces>?


What you would look for in XML Schema is some manner of
referencing the other members of the document within the
maxInclusive attribute, like allowing XPath expressions.
You won't find this.

One workaround that is sometimes used is to supplement the
validation process of XML Schema with something that does
have intrinsically strong support for XPath expressions: XSLT.

After using XML Schema to validate the structural qualities of
your instance document, its possible to run an XSLT stylesheet
against the instance document that will do inter-element content
validation.

This stylesheet can be as simple as something that returns a
literal text answer to the question of validity: true or false?

It could also be sophisticated enough to return "0 OK" for valid
content, or an error message describing what is invalid, "107
More pieces of cake served (11) than exist pieces of birthday
cake (8)."
Derek Harmon
Jul 20 '05 #2

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

Similar topics

9
by: Stanimir Stamenkov | last post by:
Using Xerces2 Java I'm trying to validate a CSV data following an XNI example <http://xml.apache.org/xerces2-j/xni-config.html#examples>. The CSV scanner generates XML tree events like: <csv>...
0
by: Rajesh Jain | last post by:
I Have 2 separate schemas. --------------Schema 1 is defined as below----------- <xs:schema targetNamespace="http://Schemas/1" xmlns="http://Schemas/1" xmlns:xs="http://www.w3.org/2001/XMLSchema"...
1
by: shakuf | last post by:
hi i would like to define a type with restrictions, i used the following schema but i get an error <xs:element name="Latitude"> <xs:complexType> <xs:simpleContent> <xs:extension...
4
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all...
0
by: beyonddc.storage | last post by:
Below is my current schema <xs:simpleType name="LongType"> <xs:restriction base="xs:long"> </xs:restriction> </xs:simpleType> <xs:simpleType name="MaxLong"> <xs:restriction base="LongType">...
1
by: Stefan Reiter | last post by:
Hi, I want to limit a date to a minDate and a maxDate - is that possible, and how? <xs:simpleType> <xs:restriction base="xs:date"> <xs: </xs:restriction> </xs:simpleType> I assume it is...
1
by: Stefan Reiter | last post by:
Hi, I want to limit a date to a minDate and a maxDate - is that possible, and how? <xs:simpleType> <xs:restriction base="xs:date"> <xs: </xs:restriction> </xs:simpleType> I assume it is...
4
by: Stan R. | last post by:
Hello, I have xmllint and xsltproc installed and running on both my linux and win32 platforms, all seems good. I have a couple questions though. 1) If I have an external dtd file, which is...
1
by: Paul Johnston | last post by:
Hi Working my way through "Learning XML" by Erik Ray and have a question if someone can help me. Using Oxygen 7.2 Doing the section on XML Schema And have a problem with the section below...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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...

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.