Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Expressing dynamics in XML ?

Reply
Thread Tools

Expressing dynamics in XML ?

 
 
mathieu
Guest
Posts: n/a
 
      08-10-2009
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
 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      08-11-2009
Steve W. Jackson wrote:
> A person's date of birth doesn't change.


Definitely the best answer. Save birthdate and calculate age.
 
Reply With Quote
 
 
 
 
mathieu
Guest
Posts: n/a
 
      08-11-2009
On Aug 10, 6:19*pm, "Steve W. Jackson" <(E-Mail Removed)>
wrote:
> In article
> <(E-Mail Removed)>,
>
> *mathieu <(E-Mail Removed)> wrote:
> > 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

>
> 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
 
Reply With Quote
 
Mayeul
Guest
Posts: n/a
 
      08-11-2009
mathieu wrote:
> On Aug 10, 6:19 pm, "Steve W. Jackson" <(E-Mail Removed)>
> wrote:
>> In article
>> <(E-Mail Removed)>,
>>
>> mathieu <(E-Mail Removed)> wrote:
>>> 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

>> 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">


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.

--
Mayeul
 
Reply With Quote
 
mathieu
Guest
Posts: n/a
 
      08-11-2009
On Aug 11, 2:45*pm, Mayeul <(E-Mail Removed)> wrote:
> mathieu wrote:
> > On Aug 10, 6:19 pm, "Steve W. Jackson" <(E-Mail Removed)>
> > wrote:
> >> In article
> >> <(E-Mail Removed)>,

>
> >> *mathieu <(E-Mail Removed)> wrote:
> >>> 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
> >> 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">

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


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,
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      08-11-2009
mathieu wrote:
> 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.

 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      08-11-2009
Mayeul wrote:
> 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).
 
Reply With Quote
 
Mayeul
Guest
Posts: n/a
 
      08-11-2009
mathieu wrote:
> On Aug 11, 2:45 pm, Mayeul <(E-Mail Removed)> wrote:
>> mathieu wrote:
>>> On Aug 10, 6:19 pm, "Steve W. Jackson" <(E-Mail Removed)>
>>> wrote:
>>>> In article
>>>> <(E-Mail Removed)>,
>>>> mathieu <(E-Mail Removed)> wrote:
>>>>> 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
>>>> 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">

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

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

--
Mayeul
 
Reply With Quote
 
mathieu
Guest
Posts: n/a
 
      08-11-2009
On Aug 11, 3:15*pm, Joe Kesselman <(E-Mail Removed)>
wrote:
> Mayeul wrote:
> > 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).


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
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      08-12-2009
mathieu wrote:
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OWL] expressing relationships Rob Heersma XML 0 06-15-2004 12:01 PM
Expressing intent in method calling... Richard Kilmer Ruby 8 06-09-2004 07:13 AM
Re: expressing a certain algebraic statement in C++ STL Michel Rosien C++ 0 04-22-2004 01:11 PM
Re: expressing a certain algebraic statement in C++ STL Mike Wahler C++ 1 04-01-2004 02:40 PM
Expressing time. Sean Python 1 07-14-2003 03:57 PM



Advertisments