RuleML / reaction-ruleml

Reaction RuleML
http://reaction.ruleml.org
8 stars 4 forks source link

Eliminating default values of attributes #10

Closed greenTara closed 10 years ago

greenTara commented 10 years ago

There is a large overhead to handling "default values" of attributes in Relax NG. And there seems to be little value added from this characteristic. The only advantages I can think of are:

  1. there is an slight improvement to human readability when the default value is made explicit, as in the normalized form
  2. ???

The principal disadvantage, from the RNC perspective, is the extra code necessary to handle this feature. As an example, here is the beginning of the coding for the RR @style attribute, which has default value "reasoning".

# *** @style ***
#
# restriction: active | messaging | reasoning
# default value: reasoning (in DR Reaction RuleML), active (in PR and ECA RuleML), and messaging (in CEP RuleML)
# optional attribute
# in style_default module
style.datatype |= "reasoning"
# in style_non-default module
style.datatype |= "active" | "messaging"
# *** @style ***
#
# restriction: active | messaging | reasoning
# default value: reasoning (in DR Reaction RuleML)
# optional attribute
style.attrib = style-att-inf.choice
# in default_inf_reactive module
style-att-inf.choice |= notAllowed
# in default_absent_reactive module
style-att-inf.choice |= empty
# in default_present_reactive module
style-att-inf.choice |= style-att.choice
# in style_attrib module
style-att.choice |= attribute style { style.datatype }

The remaining steps to implement this code would be to create the modules:

In a driver schema for the compact syntax where the attributes with default values must be absent:

include default_inf_reactive_expansion_module.rnc
include default_absent_reactive_expansion_module.rnc

In a driver schema for the normalized syntax where the attributes with default values must be present:

include default_inf_reactive_expansion_module.rnc
include default_present_reactive_expansion_module.rnc

In a driver schema for the relaxed syntax where the attributes with default values may be absent or present:

include default_inf_reactive_expansion_module.rnc
include default_absent_reactive_expansion_module.rnc
include default_present_reactive_expansion_module.rnc

In addition, when the fine-grained modularization of RR is implemented, there would need to be the following modules:

In comparison, if we drop the value "reasoning" from the style datatype, and use the absence of the style attribute as the indicator that the style is reasoning, (and similarly for @mode, @safety, @size) then

apaschke commented 10 years ago

if we drop the value "reasoning" from the style datatype, and use the absence of the style attribute as the indicator that the style is reasoning

I agree with the proposed assumption based semantics, that there is an implicitly assumed default value for attributes. These assumptions need to be documented in the schema specification then and we need to specify the semantics of these assumptions, e.g.

-Adrian

Von: Tara Athan [mailto:notifications@github.com] Gesendet: Dienstag, 28. Januar 2014 00:16 An: RuleML/reaction-ruleml Betreff: [reaction-ruleml] Eliminating default values of attributes (#10)

There is a large overhead to handling "default values" of attributes in Relax NG. And there seems to be little value added from this characteristic. The only advantages I can think of are:

  1. there is an slight improvement to human readability when the default value is made explicit, as in the normalized form
  2. ???

The principal disadvantage, from the RNC perspective, is the extra code necessary to handle this feature. As an example, here is the beginning of the coding for the RR @style https://github.com/style attribute, which has default value "reasoning".

* @style *

#

restriction: active | messaging | reasoning

default value: reasoning (in DR Reaction RuleML), active (in PR and ECA RuleML), and messaging (in CEP RuleML)

optional attribute

in style_default module

style.datatype |= "reasoning"

in style_non-default module

style.datatype |= "active" | "messaging"

* @style *

#

restriction: active | messaging | reasoning

default value: reasoning (in DR Reaction RuleML)

optional attribute

style.attrib = style-att-inf.choice

in default_inf_reactive module

style-att-inf.choice |= notAllowed

in default_absent_reactive module

style-att-inf.choice |= empty

in default_present_reactive module

style-att-inf.choice |= style-att.choice

in style_attrib module

style-att.choice |= attribute style { style.datatype }

The remaining steps to implement this code would be to create the modules:

In a driver schema for the compact syntax where the attributes with default values must be absent:

include default_inf_reactive_expansion_module.rnc include default_absent_reactive_expansion_module.rnc

In a driver schema for the normalized syntax where the attributes with default values must be present:

include default_inf_reactive_expansion_module.rnc include default_present_reactive_expansion_module.rnc

In a driver schema for the relaxed syntax where the attributes with default values may be absent or present:

include default_inf_reactive_expansion_module.rnc include default_absent_reactive_expansion_module.rnc include default_present_reactive_expansion_module.rnc

In addition, when the fine-grained modularization of RR is implemented, there would need to be the following modules:

In comparison, if we drop the value "reasoning" from the style datatype, and use the absence of the style attribute as the indicator that the style is reasoning, (and similarly for @mode https://github.com/mode , @safety https://github.com/safety , @size https://github.com/size ) then

— Reply to this email directly or view it on GitHub https://github.com/RuleML/reaction-ruleml/issues/10 . https://github.com/notifications/beacon/2492924__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwNjM5NzM0NiwiZGF0YSI6eyJpZCI6MjQzNzA3MzF9fQ==--c17c09c931326dc7168a2e2a5248f3d4e3c85607.gif

greenTara commented 10 years ago

I think we need a suite of examples. It is not clear to me how scopes are defined.

apaschke commented 10 years ago

Here the list of attributes with default values

@mode default=? @safety default=non-interrupting @per default=copy @size default=-1 @style default=reasoning

@mapMaterial default=yes @material default=yes @mapDirection default=bidirectional @direction default=bidirectional

@oriented default=no

@val default=0..

greenTara commented 10 years ago

There are only four of these attributes that "belong" to Reaction RuleML: @mode default=? @safety default=non-interrupting @size default=-1 @style default=reasoning

The others are built in to Deliberation RuleML, and we don't have the option to modify their syntax in version 1.0 (although we can always choose the Deliberation RuleML sublanguage that doesn't allow the attribute to take on its default value.)

greenTara commented 10 years ago

The initial change to be made in dr.rnc is to remove the default value from the content model of each attribute.

More explicitly the code for the style attribute is reduced to

# *** @style ***
# 
#  restriction: active | messaging  (in DR Reaction RuleML)
#      optional attribute
style.attrib = style-att.choice
style-att.choice |= attribute style { style.datatype }
style.datatype |= "active" | "messaging"
apaschke commented 10 years ago

I have removed all default value definitions in the XSD, RelaxNG XML and RNC, but kept the attribute values in the attributes content model.

greenTara commented 10 years ago

This seems like a good solution to me.

I take this to mean that normalization will make no changes to these attributes - it will not add an attribute if one is missing, nor will it take it away if its vaue is the "default" value. So it will be valid in the normalized form to have either no attribute or the attribute with any of the original values. Is this what you had in mind?

greenTara commented 10 years ago

I think we need to keep the default value of @per to be "copy". This is the way it is in Deliberation RuleML 1.0. When we modify Deliberation RuleML to get rid of the default values of attributes there, @per will be modified at that time.

greenTara commented 10 years ago

closed by 5aad12ce91e0dc70ef02c1df77d527b50ab661c9