diff --git a/svrl.xqm b/svrl.xqm index f0680dd..e80912c 100644 --- a/svrl.xqm +++ b/svrl.xqm @@ -127,9 +127,11 @@ as item()* case element(sch:name) return if($node/@path) then output:name-value-of($node/@path, $prolog, $rule-context, $context) - else name($rule-context) + [self::svrl:*] + else () case element(sch:value-of) return output:name-value-of($node/@select, $prolog, $rule-context, $context) + [self::svrl:*] default return () else {(:TODO attributes:) diff --git a/test/test-evaluate.xqm b/test/test-evaluate.xqm index c1c87e7..cf6796d 100644 --- a/test/test-evaluate.xqm +++ b/test/test-evaluate.xqm @@ -1323,4 +1323,192 @@ declare %unit:test function _:global-variable-syntax-error() No specifier after lookup operator: ';'. @value='?' ) ) +}; + +declare %unit:test function _:pattern-variable-syntax-error() +{ + let $result := + eval:schema( + document{}, + + + + + + + + , + '', + map{'dry-run':'true'} + ) + return + ( + unit:assert-equals( + $result/svrl:failed-assert[ends-with(@location ,'/Q{http://purl.oclc.org/dsdl/schematron}pattern[1]/Q{http://purl.oclc.org/dsdl/schematron}let[1]/@value')] + /svrl:text, + Incomplete FLWOR expression, expecting 'return'. @value='$' + ) + ) +}; + +declare %unit:test function _:rule-context-syntax-error() +{ + let $result := + eval:schema( + document{}, + + + + + + + , + '', + map{'dry-run':'true'} + ) + return + ( + unit:assert-equals( + $result/svrl:failed-assert/svrl:text, + Expecting expression. @context='' + ) + ) +}; + +declare %unit:test function _:dry-run-all-rules-processed() +{ + let $result := + eval:schema( + document{}, + + + + + + + , + '', + map{'dry-run':'true'} + ) + return + ( + unit:assert-equals( + count($result/svrl:fired-rule), + 2 + ) + ) +}; + +declare %unit:ignore function _:rule-variable-syntax-error() +{ + let $result := + eval:schema( + document{}, + + + + + + + + , + '', + map{'dry-run':'true'} + ) + return + ( + unit:assert-equals( + count($result/svrl:failed-assert[ends-with(@location, '/Q{http://purl.oclc.org/dsdl/schematron}pattern[1]/Q{http://purl.oclc.org/dsdl/schematron}rule[1]/@context')]), + 1 + ), + unit:assert-equals( + $result/svrl:failed-assert[ends-with(@location, '/Q{http://purl.oclc.org/dsdl/schematron}pattern[1]/Q{http://purl.oclc.org/dsdl/schematron}rule[1]/@context')] + /svrl:text, + TODO + ) + ) +}; + +declare %unit:test function _:report-test-syntax-error() +{ + let $result := + eval:schema( + document{}, + + + + + + + , + '', + map{'dry-run':'true'} + ) + return + ( + unit:assert-equals( + count($result/svrl:failed-assert[ends-with(@location, '/Q{http://purl.oclc.org/dsdl/schematron}pattern[1]/Q{http://purl.oclc.org/dsdl/schematron}rule[1]/Q{http://purl.oclc.org/dsdl/schematron}report[1]/@test')]), + 1 + ), + unit:assert-equals( + $result/svrl:failed-assert/svrl:text, + Namespace prefix not declared: ns. @test='ns:*' + ) + ) +}; + +declare %unit:test function _:name-path-syntax-error() +{ + let $result := + eval:schema( + document{}, + + + + + + + , + '', + map{'dry-run':'true'} + ) + return + ( + unit:assert-equals( + count($result/svrl:failed-assert[ends-with(@location, '/Q{http://purl.oclc.org/dsdl/schematron}pattern[1]/Q{http://purl.oclc.org/dsdl/schematron}rule[1]/Q{http://purl.oclc.org/dsdl/schematron}report[1]/Q{http://purl.oclc.org/dsdl/schematron}name[1]/@path')]), + 1 + ), + unit:assert-equals( + $result/svrl:failed-assert/svrl:text, + Unexpected end of query: '.'. @path='...' + ) + ) +}; + +declare %unit:test function _:value-of-select-syntax-error() +{ + let $result := + eval:schema( + document{}, + + + + + + + , + '', + map{'dry-run':'true'} + ) + return + ( + unit:assert-equals( + count($result/svrl:failed-assert[ends-with(@location, '/Q{http://purl.oclc.org/dsdl/schematron}pattern[1]/Q{http://purl.oclc.org/dsdl/schematron}rule[1]/Q{http://purl.oclc.org/dsdl/schematron}report[1]/Q{http://purl.oclc.org/dsdl/schematron}value-of[1]/@select')]), + 1 + ), + unit:assert-equals( + $result/svrl:failed-assert/svrl:text, + Unexpected end of query: '.'. @select='...' + ) + ) }; \ No newline at end of file