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

X

xan2

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.
 
M

Martin Honnen

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.
 
X

xan2

Martin said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top