Expressing dynamics in XML ?

M

mathieu

Hi there,

I am looking at a way to express dynamic in XML. For example let say
I have :

....
<person name="John Doe" Age="30">
....

How can I say that every year Age should be increased by 1 ? Has
anyone work on integrating language and storing it as XML ?

thanks
 
M

mathieu

A person's date of birth doesn't change.  Include that and then the
"age" information will always be accurate when calculated from a
specified date.

Excellent. So I now have:

<person name="John Doe" Bday="197001001">

How do I express the rule Age is computed from Bday using current
date ? I am looking at MathML, but it is missing a for-each which may
come handy when I'd like to define more complex rules.

Are RuleML and SMRL being used ?

Thanks
 
M

Mayeul

mathieu said:
Excellent. So I now have:

<person name="John Doe" Bday="197001001">

I suggest a more standard date format, for instance 1970-01-01 (yyyy-mm-dd)
How do I express the rule Age is computed from Bday using current
date ?

I suggest you programmatically do that in whatever program will ever use
your XML as input. XML is meant to represent, and therefore exchange,
data. It is rarely meant to apply data computing.
I am looking at MathML, but it is missing a for-each which may
come handy when I'd like to define more complex rules.

As far as I know MathML's purpose is to represent mathematic formulas,
not to calculate them.
In other words it is a method to put math sentences in a web page or
likewise, it is not a programming language.
In other other words, MathML is not what you're looking for.

It seems to me you are trying to use XML as a programming language,
which is rarely meant to be, aside from XSL transformation (which is not
meant for the kind of programming you want to do.)
Are RuleML and SMRL being used ?

Can't comment on these, don't know them.
 
M

mathieu

I suggest a more standard date format, for instance 1970-01-01 (yyyy-mm-dd)


I suggest you programmatically do that in whatever program will ever use
your XML as input. XML is meant to represent, and therefore exchange,
data. It is rarely meant to apply data computing.

Just like XML is meant to exchange data, I am looking for a standard
to exchange rules and dynamics. Looks like w3c is working on it:

http://www.w3.org/2005/rules/wiki/RIF_Working_Group

I'll see if this is a good entry point.

Thanks anyway,
 
J

Joe Kesselman

mathieu said:
How do I express the rule Age is computed from Bday using current
date ?

Depends on how you're processing the XML. Most of us would do this
computation in the application code which is actually going to use the
age value.

If you want to stay in the XML-standards domain, one approach would be
to use XPath or XSLT; the 2.0 versions of those added support for schema
datatypes, including dates and durations and operations upon them.
 
J

Joe Kesselman

Mayeul said:
It seems to me you are trying to use XML as a programming language,
which is rarely meant to be, aside from XSL transformation (which is not
meant for the kind of programming you want to do.)

Agree with that analysis. XML itself is pretty close to being raw syntax
for data structures. Those structures certainly *can* express
programming operations (XSLT being the obvious example but not the only
one), but even when that's done the document which describes the
operations is generally separate from the document which describes the
data to be operated on.

Much the same as the separation of program and data files in any other
syntax(es).
 
M

Mayeul

mathieu said:
Just like XML is meant to exchange data, I am looking for a standard
to exchange rules and dynamics. Looks like w3c is working on it:

http://www.w3.org/2005/rules/wiki/RIF_Working_Group

I'll see if this is a good entry point.

My mistake, so this really is what you want to do.

I'm sure a lot of standard recommendations and drafts were made, and are
being done, in this area. I'm not even close to start understanding
their point, though.

Good luck with your research.
 
M

mathieu

Agree with that analysis. XML itself is pretty close to being raw syntax
for data structures. Those structures certainly *can* express
programming operations (XSLT being the obvious example but not the only
one), but even when that's done the document which describes the
operations is generally separate from the document which describes the
data to be operated on.

Much the same as the separation of program and data files in any other
syntax(es).

I see your point. I'll try to keep that in mind.
The word 'rule' might be poorly chosen though, how about 'constrain'.
You still want to write your 'rule' in xslt to make your xml goes from
one state to the other.

Now consider

<person name="John Doe" Balance="100"/>
<item name="dvd" price="10"/>

Each time you buy a dvd, your balance goes down by 10, which can be
expressed in your xslt script. However I can see different type of
constrain: depending if your bank allows you to have a balance below 0
or not.
The constrain -as I see it- are more like 'data', it is defined when
you open your account. And you still somehow need to say <bank-account
is-valid-if="$balance > $limit"/>

I am not sure it actually make sense, but I am just discovering the
field.

Thx anyway
 
J

Joe Kesselman

mathieu said:
Each time you buy a dvd, your balance goes down by 10, which can be
expressed in your xslt script.

I wouldn't do that kind of transaction in XSLT. I'd do it in Java, or
some other straight programming language.

The fact that XSLT (and now XQuery) *can* be pressed into service as
fairly general programming languages doesn't mean they necessarily
should be.
 

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
474,005
Messages
2,570,264
Members
46,859
Latest member
HeidiAtkin

Latest Threads

Top