(defrule VALIDATE:dataset-variables
(page "edit-dataset.xslt")
?dataset <- (dataset (variables $?) (has-errors FALSE))
?errors <- (accumulate (bind ?list (new java.util.ArrayList))
(?list add ?var)
?list
(dataset (variables $? ?var&:
(not (regexp "^[a-zA-Z_][a-zA-Z0-9_\\.]*$"
?var)) $?)))
=>
(printout t "errors = " (?errors toString) crlf)
(modify ?dataset
; TODO: set variablesErrors for each variable in ?errors"
(has-errors TRUE)))
It looks like this works and is very cool but if I have more then one dataset
how do I get the ?dataset and ?errors to correlate?
test-facts.clp
...
(page "edit-dataset.xslt")
(dataset
(name "testdata")
(nobs "120")
(nvars "10")
(variables "X1" "X-2" "X3")
(submitEditDatasetForm "Submit"))
...
This copy of Jess will expire in 106 day(s).
executing...
errors = [X-2]
f-0 (MAIN::initial-fact)
f-1 (MAIN::nextPage "edit-dataset.xslt")
f-2 (MAIN::R nil)
f-3 (MAIN::subscription-prices (maxDataElements 500) (monthlyPrice 25)
(yearlyPrice 100))
f-4 (MAIN::upload-info (uploadDirectory "/tmp/Rserv") (filename "test.csv")
(contentType "text/plain") (contentTypeError "") (length 53) (format "fwf")
(separationChar ",") (columnWidths "2 8 10 5 15") (hasColumnNames "TRUE")
(submitUploadForm nil) (submitDatasetForm nil) (submitShowDatasetForm nil)
(has-errors FALSE))
f-5 (MAIN::page "edit-dataset.xslt")
f-6 (MAIN::dataset (name "testdata") (nameError "") (nobs "120") (nvars "10")
(variables "X1" "X-2" "X3") (variableErrors ) (variableTypes )
(submitEditDatasetForm "Submit") (has-errors TRUE) (isFree TRUE))
f-7 (MAIN::purchase-info (creditCardNumber "1408 0412 3456 7893")
(creditCardNumberError "") (creditCardType "") (securityCode "143")
(securityCodeError "") (expirationDate "05-2010") (expirationDateError "")
(nameOnCard "Donald P Winston") (nameOnCardError "") (subscription nil)
(subscriptionError "") (submitPurchaseSubscriptionForm nil) (has-errors FALSE))
For a total of 8 facts in all modules.
Donald Paul Winston
[email protected]