RuleML / issues-ruleml

A repository solely for RuleML issues. No schemas or documents should be committed here.
3 stars 3 forks source link

XSLT test script (batch_xslt_test-normal.sh) fails because PSOA is not sublanguage of nafholog #82

Closed greenTara closed 4 years ago

greenTara commented 5 years ago

The script whose failure prompted the creation of this issue is this one:

https://github.com/RuleML/deliberation-ruleml/blob/1.03-psoa/bash/batch_xslt_test-normal.sh

greenTara commented 5 years ago

Change

if [[ ! "${file}" =~ fail ]] && [[ "${exitvalue}" -ne "0" ]]; then

to

if [[ ! "${file}" =~ fail ]] && [[ ! "${file}" =~ PSOA ]] && [[ "${exitvalue}" -ne "0" ]]; then

Also change

      echo "XSD Validation Failed for Normal ${file}"

to

      echo "XSD Validation Failed for Normal non-PSOA ${file}"
greenTara commented 5 years ago

Also add blocks for validating against the most general PSOA schema:

pschemaname="naffologeqPSOA_normal.xsd" pfile="${XSD_HOME}${pschemaname}"
"${BASH_HOME}aux_valxsd.sh" "${pfile}" if [[ "$?" -ne "0" ]]; then echo "Schema Validation Failed for ${pschemaname}" exit 1 fi

"${BASH_HOME}aux_valxsd.sh" "${pfile}" "${file}"
exitvalue=$?
if [[ ! "${file}" =~ fail ]] && [[ "${file}" =~ PSOA ]] && [[ "${exitvalue}" -ne "0" ]]; then
      echo "XSD Validation Failed for Normal PSOA ${file}"
      exit 1
fi
greenTara commented 5 years ago

Similarly modify for RNC validation.

greenTara commented 4 years ago

Review: The above modifications created a work-around for the problem, but is an fragile solution. It would be better if the test would not depend on having some key string in the filename. Also, because such sidewise extensions may in general produce a RuleML language structure that has multiple maximal elements, it would be better to revise the logic of the script so that it can be configured to have an arbitrary number of maximal elements.

greenTara commented 4 years ago

The problem: The troublesome lines are these:

"${BASH_HOME}aux_valxsd.sh" "${sfile}" "${file}"

"${BASH_HOME}aux_valrnc.sh" "${sfile2}" "${file}"

Here "file" is the output instance of an XSLT transformation while "sfile" and "sfile2" are supposed to be the "supremum" schemas (in XSD and RNC, resp.) in the expected serialization (in this case, the normalized serialization.) However for the PSOA extension there is no supremum (a supremum in this context would be a language which contained all other languages in the family, see https://en.wikipedia.org/wiki/Infimum_and_supremum)

What needs to be done instead of these calls is a set of such calls, one for each maximal element of the family. The test passes if any one of the validation calls succeeds. Since this set of calls will be invoked more than once, we will write new scripts to invoke these calls. One script is for XSD validation, the other for RNC validation.

The new scripts will have input parameters and run non-recursively (not batch) so the filenameof the script will start with "aux". Let's call them "aux_disjunctvalxsd" and "aux_disjunctvalrnc". The string "disjunct" (short for "disjunction" which means "choice" or "logical OR") indicates that it is enough for the instance to successfully validate against one of the schemas specified in the configuration text file described below.

The input parameters are

  1. the filename of (or relative path to) the configuration file (a text file containing the anchor filename (without serialization suffix or extension) of each schema to be employed),
  2. the instance file, and
  3. a string with the suffix for the serialization ("relaxed", "normal" or "compact").

Configuration Text File: Filename: config_max.txt Contents:

nafhologeq
naffologeqPSOA

The new script will have a "while read line" loop (see https://github.com/RuleML/deliberation-ruleml/blob/1.03-psoa/bash/batch_config2rnc.sh) that runs over the lines of the configuration file config_max.txt. For each line of the configuration file, the corresponding schema filename is constructed by string concatenation. Then the schema is applied to the instance file with a call to aux_valxsd.sh or aux_valrnc.sh, as appropriate.

The script could employ a shortcut disjunction - whenever a validation is successful, the script exits with code "0", otherwise the loop will continue. If the loop completes that means none of the validations have been successful, so the script exits with code "1".

greenTara commented 4 years ago

The outcome of invoking aux_disjunctvalxsd.sh can be represented by several cases using instances from the test suites: Case 1. ackermann (originally from https://github.com/RuleML/deliberation-ruleml/blob/1.03-psoa/test/xsd-test-suites/Hornlog/hornlogeq/ackermann.ruleml) Because hornlogeq is a sublanguage of both naffolgeqPSOA and nafhologeq, this instance will validate against both of these maximal schemas. SUCCEEDS (The variable $? has value 0)

Case 2. bookSellerAuthor (orignally in https://github.com/RuleML/deliberation-ruleml/blob/1.03-psoa/test/xsd-test-suites/SWSL/hohornlogeq/bookSellerAuthor.ruleml) The instance uses Uniterm elements- it is an instance of nafhologeq but not naffologeqPSOA. Because it validates against one of the maximal schemas, the result is SUCCEEDS. Case 3. hornlogPSOA (originally in https://github.com/RuleML/deliberation-ruleml/blob/1.03-psoa/test/xsd-test-suites/hornlogPSOA-test-suite/hornlogPSOA.ruleml) The instance uses slotdep and Tuple elements- it is an instance of naffologeqPSOA but not nafhologeq. Because it validates against one of the maximal schemas, the result is SUCCEEDS. Case 4. Note: In the above cases, we use instances that have been normalized by the XSLT normalizer, and we assume, during our test-driven development of this bash script, that the normalizer is working correctly! Now ... there is a need to test that the aux_disjunctvalxsd script FAILS when it should - that is, when the instance is not valid against either maximal schema. There are two options, and if time permits I suggest to do both. a. The first is to use an existing instance that is not normalized, e.g. the original ackermann instance, before applying the normalizer. b. The second would be to take a holog instance, like booksellerAuthor, and add a PSOA feature to it (E.g. wrap Uniterm arguments in a Tuple element). BTW it should be named booksellerAuthorPSOA_fail, since it is outside the current scope of PSOA.