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

xan2

Usenet Archive
Joined
May 1, 2006
Messages
8
Reaction score
0
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.
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
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.
 

xan2

Usenet Archive
Joined
May 1, 2006
Messages
8
Reaction score
0
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
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top