Expressing dynamics in XML ?

Discussion in 'XML' started by mathieu, Aug 10, 2009.

  1. mathieu

    mathieu Guest

    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
     
    mathieu, Aug 10, 2009
    #1
    1. Advertising

  2. Steve W. Jackson wrote:
    > A person's date of birth doesn't change.


    Definitely the best answer. Save birthdate and calculate age.
     
    Joe Kesselman, Aug 11, 2009
    #2
    1. Advertising

  3. mathieu

    mathieu Guest

    On Aug 10, 6:19 pm, "Steve W. Jackson" <>
    wrote:
    > In article
    > <>,
    >
    >  mathieu <> 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
     
    mathieu, Aug 11, 2009
    #3
  4. mathieu

    Mayeul Guest

    mathieu wrote:
    > On Aug 10, 6:19 pm, "Steve W. Jackson" <>
    > wrote:
    >> In article
    >> <>,
    >>
    >> mathieu <> 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
     
    Mayeul, Aug 11, 2009
    #4
  5. mathieu

    mathieu Guest

    On Aug 11, 2:45 pm, Mayeul <> wrote:
    > mathieu wrote:
    > > On Aug 10, 6:19 pm, "Steve W. Jackson" <>
    > > wrote:
    > >> In article
    > >> <>,

    >
    > >>  mathieu <> 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,
     
    mathieu, Aug 11, 2009
    #5
  6. 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.
     
    Joe Kesselman, Aug 11, 2009
    #6
  7. 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).
     
    Joe Kesselman, Aug 11, 2009
    #7
  8. mathieu

    Mayeul Guest

    mathieu wrote:
    > On Aug 11, 2:45 pm, Mayeul <> wrote:
    >> mathieu wrote:
    >>> On Aug 10, 6:19 pm, "Steve W. Jackson" <>
    >>> wrote:
    >>>> In article
    >>>> <>,
    >>>> mathieu <> 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
     
    Mayeul, Aug 11, 2009
    #8
  9. mathieu

    mathieu Guest

    On Aug 11, 3:15 pm, Joe Kesselman <>
    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
     
    mathieu, Aug 11, 2009
    #9
  10. 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.
     
    Joe Kesselman, Aug 12, 2009
    #10
    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.
Similar Threads
  1. Floyd Pepper
    Replies:
    0
    Views:
    743
    Floyd Pepper
    Sep 14, 2003
  2. Gonzalo Aguirre

    creating dynamics derived classes

    Gonzalo Aguirre, Jan 12, 2004, in forum: C++
    Replies:
    4
    Views:
    339
    David White
    Jan 13, 2004
  3. Alberto Santini

    Real-Time Fluid Dynamics for Games...

    Alberto Santini, Feb 20, 2005, in forum: Python
    Replies:
    2
    Views:
    1,232
    Alberto Santini
    Feb 21, 2005
  4. Tony Johansson

    use dynamics port

    Tony Johansson, Jan 9, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    668
    Benjamin Fallar III
    Jan 9, 2010
  5. Steven Parkes

    memprof / GC dynamics

    Steven Parkes, Feb 23, 2010, in forum: Ruby
    Replies:
    1
    Views:
    104
    Roger Pack
    Feb 24, 2010
Loading...

Share This Page