XML Schema Semantics validation

Discussion in 'XML' started by pal.girish@gmail.com, Mar 30, 2007.

  1. Guest

    Hi,
    I am totally new to XML. I would like to know is there any way to
    enforce rules in XML through XML schema such that value of one
    attribute in some elemnet is validated against values of other
    attributes in other elements. For eg
    if
    <fruit name=apple cost=5>
    </fruit>
    <fruit name=grapes cost=10>
    </fruit>

    now i need to check that cost of grapes is always greater than apple
    can i do it through XML schema or I will need to parse the tree using
    some programming language and then do all these types of validations

    Thanks,
    Girish
    , Mar 30, 2007
    #1
    1. Advertising

  2. wrote:

    > if
    > <fruit name=apple cost=5>
    > </fruit>
    > <fruit name=grapes cost=10>
    > </fruit>
    >
    > now i need to check that cost of grapes is always greater than apple
    > can i do it through XML schema or I will need to parse the tree using
    > some programming language and then do all these types of validations


    XSD schemas can't express such constraints relating to different
    attribute values. You can express such constraints with the Schematron
    language, see <http://www.schematron.com/>.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Mar 30, 2007
    #2
    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.

Share This Page