1 | xquery version "1.0"; |
---|
2 | (:~~~~~~~~~~~~~~~~~~~~~~~~~~ Conformance Test ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
3 | Test Number: 007 |
---|
4 | Description: Asserts unique @xmi.id values in the XMI file |
---|
5 | Reference: An apparent bug in EA export can duplicate tagged values |
---|
6 | for the root package. It may not be a 'bug' per se as it |
---|
7 | seems to have appeared in the GeoSciML model only after |
---|
8 | manual user errors with synchrnonization of dependent packages. |
---|
9 | For this reason it's worth including a test for it. |
---|
10 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:) |
---|
11 | |
---|
12 | import module namespace mod-fr = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:framework" |
---|
13 | at "#{ROOT_URL}ISO19136-AnxE/modules/module-framework-functions.xq"; |
---|
14 | |
---|
15 | import module namespace mod-xp = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:xmi-proc" |
---|
16 | at "#{ROOT_URL}ISO19136-AnxE/modules/module-xproc-functions.xq"; |
---|
17 | |
---|
18 | declare namespace UML = "omg.org/UML1.3"; |
---|
19 | declare namespace cr = "http://ndg.service.newmoon.conftest-result/1.0"; |
---|
20 | |
---|
21 | (: Declare local variables, particular to this test :) |
---|
22 | declare variable $test-num as xs:integer := 7; |
---|
23 | declare variable $pass-msg as xs:string := "Each element in the XMI document does have a unique value of @xmi.id."; |
---|
24 | declare variable $fail-msg as xs:string := "Model element has non-unique @xmi.id as follow:"; |
---|
25 | |
---|
26 | (: |
---|
27 | Declare the local assert function which defines a postive condition for pass. |
---|
28 | |
---|
29 | #EditedBy: Krupali Patel |
---|
30 | #Note: Improved diagnostic message. |
---|
31 | :) |
---|
32 | declare function local:assert($doc-root as node()?) as node()? |
---|
33 | { |
---|
34 | let $fail := ( |
---|
35 | for $dup in mod-xp:get-duplicates($doc-root//@xmi.id) |
---|
36 | return |
---|
37 | if ($dup eq "") then |
---|
38 | <cr:message>@xmi.id = NULL (i.e. "").</cr:message> |
---|
39 | else |
---|
40 | <cr:message>{ concat("@xmi.id = "", $dup, "".") }</cr:message> |
---|
41 | ) |
---|
42 | return |
---|
43 | if (empty($fail)) then () |
---|
44 | else |
---|
45 | <cr:fail> |
---|
46 | <cr:messages>{ $fail }</cr:messages> |
---|
47 | </cr:fail> |
---|
48 | }; |
---|
49 | |
---|
50 | (: Create a new result element :) |
---|
51 | mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/)) |
---|