XML Schemas: Advanced Validation

Discussion in 'XML' started by pr@paulrichards.me.uk, Mar 13, 2008.

  1. Guest

    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:sequence> or 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, 2008
    #1
    1. Advertising

  2. 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:sequence> or 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
    Joseph Kesselman, Mar 13, 2008
    #2
    1. Advertising

  3. 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:sequence> or 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/
    Martin Honnen, Mar 13, 2008
    #3
  4. Guest

    On 13 Mar, 13:42, Martin Honnen <> wrote:
    > 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:sequence> or 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, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Divya Alice George

    A query regarding validation of xml-schemas

    Divya Alice George, Oct 10, 2003, in forum: XML
    Replies:
    1
    Views:
    359
    Martin Boehm
    Oct 10, 2003
  2. Tony Prichard
    Replies:
    0
    Views:
    716
    Tony Prichard
    Dec 12, 2003
  3. Dominique
    Replies:
    3
    Views:
    449
    Dominique
    Jun 29, 2004
  4. Water Cooler v2
    Replies:
    3
    Views:
    878
    Andy Dingley
    May 18, 2008
  5. Michele Simionato
    Replies:
    1
    Views:
    586
    Lacrima
    Mar 27, 2010
Loading...

Share This Page