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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/ISO19136-AnxE/test-002.xq@8706
Revision 8191, 2.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:    002
4Description:    Asserts the existence of exactly one outermost UML:Package
5                                with the stereotype <<Application Schema>>. In following
6                                tests refered to as the "target Application Schema package".
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
13declare namespace UML   = "omg.org/UML1.3";
14declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
15
16(: Declare local variables, particular to this test :)
17declare variable $test-num as xs:integer := 2;
18declare variable $pass-msg as xs:string := "The root (outermost) package does have the stereotype &lt;&lt;Application Schema&gt;&gt; AND no other package has the stereotype &lt;&lt;Application Schema&gt;&gt;.";
19declare variable $fail-msg as xs:string := "The model is not serialized properly because:";
20
21(:
22        #Date:          2008-11-28
23        #Author:        Pavel Golodoniuc
24       
25
26        Declare the local assert function which defines a postive condition for pass.
27:)
28declare function local:assert($doc-root as node()?) as node()?
29{
30        let
31                $packages := $doc-root//UML:Package,
32                $fail-root := (
33                        if ($packages[1]/UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq "stereotype" and @value = ("Application Schema", "applicationSchema")]) then ()
34                        else
35                                <cr:message>{ concat("The root (outermost) package ", $packages[1]/@name, " does NOT have the stereotype &lt;&lt;Application Schema&gt;&gt;.") }</cr:message>
36                ),
37                $fail-nested := (
38                        for $pck in $packages[position() gt 1]
39                        return
40                                if ($pck[1]/UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq "stereotype"]/@value != ("Application Schema", "applicationSchema")) then ()
41                                else
42                                        <cr:message>{ concat("The package ", $pck[1]/@name, " has the stereotype &lt;&lt;Application Schema&gt;&gt; but it is not the root (outermost) package.") }</cr:message>
43                )
44        return
45                if (empty($fail-root) and empty($fail-nested)) then ()
46                else
47                        <cr:fail>
48                                <cr:messages>{ $fail-root, $fail-nested }</cr:messages>
49                        </cr:fail>
50};
51
52(: Create a new result element :)
53mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/))
Note: See TracBrowser for help on using the repository browser.