472,121 Members | 1,430 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

XML Schemas: Advanced Validation

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
3 2294
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
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
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.

Similar topics

reply views Thread by Stylus Studio | last post: by
4 posts views Thread by anonymous | last post: by
1 post views Thread by peter.moss | last post: by
5 posts views Thread by Donal McWeeney | last post: by
reply views Thread by mgoold2002 | last post: by
5 posts views Thread by Arndt Jonasson | last post: by
reply views Thread by leo001 | last post: by

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.