source: mauRepo/ISO19136-AnxE/test-007.xq @ 8190

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/ISO19136-AnxE/test-007.xq@8190
Revision 8190, 2.0 KB checked in by mnagni, 8 years ago (diff)

Share project "ISO19136-AnxE" into " http://proj.badc.rl.ac.uk/svn/ndg/mauRepo"

Line 
1xquery version "1.0";
2(:~~~~~~~~~~~~~~~~~~~~~~~~~~ Conformance Test  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3Test Number:    007
4Description:    Asserts unique @xmi.id values in the XMI file
5Reference:              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
12import module namespace mod-fr = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:framework"
13at "modules/module-framework-functions.xq";
14
15import module namespace mod-xp = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:xmi-proc"
16at "modules/module-xproc-functions.xq";
17
18declare namespace UML   = "omg.org/UML1.3";
19declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
20
21(: Declare local variables, particular to this test :)
22declare variable $test-num as xs:integer := 7;
23declare variable $pass-msg as xs:string := "Each element in the XMI document does have a unique value of @xmi.id.";
24declare 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:)
32declare 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. &quot;&quot;).</cr:message>
39                        else
40                                <cr:message>{ concat("@xmi.id = &quot;", $dup, "&quot;.") }</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 :)
51mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/))
Note: See TracBrowser for help on using the repository browser.