By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,179 Members | 2,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,179 IT Pros & Developers. It's quick & easy.

XML Schemas: Advanced Validation

P: n/a
pr
Is it possible to use an XML Schema to ensure that the data in one
attribute is less than or equal to the value in another?

Is it possible, through the use of the <xsd:sequenceor similar, to
ensure than a multiplicity is equal to the value held in another
attribute?

In case anyone is interested, I am storing knitting charts in XML, for
use in a Java application. They are a 2x2 matrix and I store the
number of rows as an attribute of the chart (which is the root
element). Each row is a child element of the chart, but there must be
exactly as many rows as is specified. Storing the size helps my
program to process the file into an array. I also want to store
certain data about the columns in the chart, these are referred to as
a number and of course this number must be less than or equal to the
total number of columns.

Mar 13 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
pr@paulrichards.me.uk wrote:
Is it possible to use an XML Schema to ensure that the data in one
attribute is less than or equal to the value in another?

Is it possible, through the use of the <xsd:sequenceor similar, to
ensure than a multiplicity is equal to the value held in another
attribute?
No, and no. Cross-validation constraints are not currently handled by
XML Schema with the exception of key/keyref and id/idref. Implement
those in your application code. Think of schema as higher-level syntax
constraints; your application is responsible for semantics.

(Some of the alternative schema languages do support cross-constaints,
but of course those have the issue of not being as widely supported or,
in some sense, as "official". Rumor has it that a future version of XML
Schema is considering picking up some of those capabilites, but I don't
know how real that is or what its status might be.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 13 '08 #2

P: n/a
pr@paulrichards.me.uk wrote:
Is it possible to use an XML Schema to ensure that the data in one
attribute is less than or equal to the value in another?
Not with the W3C XML schema language.
Is it possible, through the use of the <xsd:sequenceor similar, to
ensure than a multiplicity is equal to the value held in another
attribute?
What is a multiplicity? If you want to make sure a value in one element
or attribute is the same as the value in another element or attribute
then you can use xs:key/keyref to specify that constraint.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 13 '08 #3

P: n/a
pr
On 13 Mar, 13:42, Martin Honnen <mahotr...@yahoo.dewrote:
p...@paulrichards.me.uk wrote:
Is it possible to use an XML Schema to ensure that the data in one
attribute is less than or equal to the value in another?

Not with the W3C XML schema language.
Is it possible, through the use of the <xsd:sequenceor similar, to
ensure than a multiplicity is equal to the value held in another
attribute?

What is a multiplicity? If you want to make sure a value in one element
or attribute is the same as the value in another element or attribute
then you can use xs:key/keyref to specify that constraint.

--

* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/
By mutltiplicity, I mean how many child elements are related to the
parent element. And I don't want to make two attributes the same,
just place a constraint on one that it is less than the other.

It looks like its not possible to do these things which is fine, I
will use the schema for gross validation and do the more complex stuff
in my application. Thanks for the replies, folks.
Mar 13 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.