[XML Schema] Value of a field depending to other fields?

Discussion in 'XML' started by xan2@ono.com, May 1, 2006.

  1. Guest

    Hi,

    I just want to know if it's possible to declare a value of a field in
    XML Schema depending to other fields.

    For example, suppose we have (in pseudo-xml not in xsd) a person who
    have this fields:

    <person>
    <name> .... </name>
    <hoursofwork> </hoursofwork>
    <salaryperhour> </salaryperhour>
    <salarypermonth> <salarypermonth>
    <percentofwork> </percentofwork>
    </person>

    - name is string
    - hoursofwork is number of hours person work in a month. So we have
    that 0<= hoursofwork <= 744
    - salaryperhour is what he/she receives per hour (it could be unsigned
    int)
    - salarypermonth is only salaryperhour plus hoursofwork
    - percent of work is the percent of work a person do respecting to the
    total of amount of hours of work of all person of the enterprise

    So, we need (in pseudocode) that:

    1) salarypermonth = hoursofwork * salaryperhour
    2) percentofwork = hoursofwork/(TOTAL WORK), where TOTAL WORK = Sum of
    all hoursofwork of all intances of xml file

    Is it possible to do it with XML Schemas. I suspect that no, and that
    we need some more stronger tool combined with schema (like OWL). Can
    you answer me?

    Thank you very much,
    Xan.
     
    , May 1, 2006
    #1
    1. Advertising

  2. wrote:


    > So, we need (in pseudocode) that:
    >
    > 1) salarypermonth = hoursofwork * salaryperhour
    > 2) percentofwork = hoursofwork/(TOTAL WORK), where TOTAL WORK = Sum of
    > all hoursofwork of all intances of xml file
    >
    > Is it possible to do it with XML Schemas.


    You can't express such constraints with a W3C XML schema. Schematron
    might be able to express the constraints.
    On the other hand it looks a bit as you are trying to store data in XML
    which should not be stored at all but rather computed when it is needed.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 1, 2006
    #2
    1. Advertising

  3. Guest

    Re: Value of a field depending to other fields?

    Martin Honnen wrote:
    > wrote:
    >
    >
    > > So, we need (in pseudocode) that:
    > >
    > > 1) salarypermonth = hoursofwork * salaryperhour
    > > 2) percentofwork = hoursofwork/(TOTAL WORK), where TOTAL WORK = Sum of
    > > all hoursofwork of all intances of xml file
    > >
    > > Is it possible to do it with XML Schemas.

    >
    > You can't express such constraints with a W3C XML schema. Schematron
    > might be able to express the constraints.


    Can you put the code here? Thanks.
    And with OWL + XML Schema is it possible to express such constraints?

    > On the other hand it looks a bit as you are trying to store data in XML
    > which should not be stored at all but rather computed when it is needed.


    Why it should not be stored _at all_. Can you explain me?

    Thanks,
    Xan.
    >
    > --
    >
    > Martin Honnen
    > http://JavaScript.FAQTs.com/
     
    , May 1, 2006
    #3
    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