source: mauRepo/ISO19136-AnxE/test-010.xq @ 8191

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

#{ROOT_URL}ISO19136-AnxE parametrized the import URLs

Line 
1xquery version "1.0";
2(:~~~~~~~~~~~~~~~~~~~~~~~~~~ Conformance Test  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3Test Number:    010
4Description:    Asserts that each name from EAStub element has corresponding
5                                record in registers or type-mapping tables depending on
6                                EAStub/@UMLType.
7Reference:   
8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:)
9
10import module namespace mod-fr = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:framework"
11at "#{ROOT_URL}ISO19136-AnxE/modules/module-framework-functions.xq";
12
13
14
15declare namespace UML   = "omg.org/UML1.3";
16declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
17declare namespace tm    = "urn:x-auscope:xmlns:CSIRO:FullMoon:package-class-map:2.0";
18declare namespace pckr  = "urn:x-auscope:xmlns:CSIRO:FullMoon:package-register:2.0";
19
20declare variable $reg_external_packages as node() external;
21
22(: Declare local variables, particular to this test :)
23declare variable $test-num as xs:integer := 10;
24declare variable $pass-msg as xs:string := "Each external dependency package does have a corresponding record in the dependency register. Each external dependency class does have a corresponding record in a ClassMap found through a register reference.";
25declare variable $fail-msg as xs:string := "Some external packages and/or classes within the model do not have corresponding records in registry or type-mapping tables.";
26declare variable $pass-pck as xs:string := "Each external dependency package does have a corresponding record in the dependency register.";
27declare variable $pass-class as xs:string := "Each external dependency class does have a corresponding record in a ClassMap found through a register reference.";
28
29(: Declare the local assert function which defines a postive condition for pass :)
30declare function local:assert($doc-root as node()?, $coll as node()) as node()*
31{
32        let (: Check external package references :)
33                $msg-package := (
34                        let $ret-package := (
35                             for $ext in $doc-root/XMI/XMI.extensions/EAStub[@UMLType eq "Package"]
36                             return
37                                    if (empty($doc-root/XMI/XMI.content/UML:Model//UML:Package[@name eq $ext/@name]) and
38                                           empty($coll/pckr:register/pckr:package[@name eq $ext/@name]) and
39                                           empty($doc-root/XMI//UML:Dependency[@client eq $ext/@xmi.id]))
40                                    then
41                                           <cr:failed>{ concat("External dependency package &quot;", $ext/@name, "&quot; does NOT have a corresponding record in the dependency register.") }</cr:failed>
42                                else
43                                 ()         
44                        )
45                        return
46                         if (empty($ret-package))
47                         then
48                             <cr:passed>{ $pass-pck }</cr:passed>
49                         else
50                             $ret-package
51                ),
52                (: Check external class references :)
53                $tmt := $coll/tm:mapping,
54                $msg-class := (
55                    let $ret-class := (
56                             for $ext in $doc-root/XMI/XMI.extensions/EAStub[@UMLType eq "Class"]
57                             let $test-tag := if ($doc-root/root()//UML:Association/UML:ModelElement.taggedValue/UML:TaggedValue[@tag/matches(., "ea_(source|target)Name") and @value eq $ext/@name]/(preceding-sibling::* | following-sibling::*)[@tag eq "direction"]/substring-before(@value, " ") = "Source") then "ea_sourceName" else "ea_targetName"
58                                 return
59                                        if (empty($tmt//tm:entry/tm:umlClass[text() eq $ext/@name]) and
60                            empty($doc-root/root()//UML:Generalization[@subtype eq $ext/@xmi.id]) and
61                            empty($doc-root/root()//UML:Association/UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq $test-tag and @value eq $ext/@name]))                                         
62                                        then
63                                               <cr:failed>{ concat("External dependency class &quot;", $ext/@name, "&quot; does NOT have a corresponding record in a ClassMap found through a register reference.") }</cr:failed>
64                                        else
65                                            ()         
66                      )
67                          return
68                             if (empty($ret-class))
69                             then
70                                 <cr:passed>{ $pass-class }</cr:passed>
71                             else
72                                 $ret-class
73                  )
74        return
75           ($msg-class, $msg-package)
76};
77
78
79declare function local:new-result($num as xs:integer, $result as node()*)
80{
81        <cr:result>
82                <cr:test number="{ $num }" />
83                {
84                        for $fl in $result
85                             return $fl         
86                }
87        </cr:result>
88};
89
90
91(: Create a new result element :)
92local:new-result($test-num, local:assert(/, $reg_external_packages))
Note: See TracBrowser for help on using the repository browser.