Skip to content

Commit

Permalink
better xspec failure messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-atherden committed Nov 22, 2023
1 parent c22c465 commit 4bdc3a2
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions xquery/get-xspec-failures.xq
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
declare namespace x="http://www.jenitennison.com/xslt/xspec";
import module namespace schematron = "http://github.com/Schematron/schematron-basex";
declare variable $sch := doc('../src/schematron.sch');
declare variable $base := substring-before(base-uri($sch),'src');

let $result := doc('../test/xspec/xspec/schematron-result.xml')
let $xspec-result := doc('../test/xspec/xspec/schematron-result.xml')

return distinct-values(
for $x in (
$result//x:test[@successful="false"]/parent::x:scenario//x:context/substring-after(@href,'/tests/')
)
order by lower-case($x)
return $x
)
let $failures := distinct-values(for $x in $xspec-result//x:test[@successful="false"]/parent::x:scenario//x:context/substring-after(@href,'/tests/')
order by lower-case($x)
return $x)

for $failure in $failures
let $filename := tokenize($failure,'/')[last()]
let $folder := $base||'/test/tests/'||substring-before($failure,$filename)
let $id := tokenize(replace($folder,'/$',''),'/')[last()]
let $xml := doc($folder||$filename)
let $sch := schematron:compile(doc($folder||$id||'.sch'))
let $svrl := schematron:validate($xml, $sch)
let $messages := schematron:messages($svrl)
return ($failure,
schematron:is-valid($svrl),
for $message in $messages
return concat(schematron:message-level($message), ': ', schematron:message-description($message))
)

0 comments on commit 4bdc3a2

Please sign in to comment.