source: mauRepo/NewmoonJSP/src/main/webapp/WEB-INF/rules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/test-002.xq @ 7841

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/NewmoonJSP/src/main/webapp/WEB-INF/rules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/test-002.xq@7841
Revision 7841, 2.4 KB checked in by mnagni, 10 years ago (diff)
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 "xmldb:exist:///db/modules/conformance-test/ISO19136-V3.2-AnxE_XMI-V1.1/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        Declare the local assert function which defines a postive condition for pass.
26:)
27declare function local:assert($doc-root as node()?) as node()?
28{
29        let
30                $packages := $doc-root//UML:Package,
31                $fail-root := (
32                        if ($packages[1]/UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq "stereotype" and @value = ("Application Schema", "applicationSchema")]) then ()
33                        else
34                                <cr:message>{ concat("The root (outermost) package ", $packages[1]/@name, " does NOT have the stereotype &lt;&lt;Application Schema&gt;&gt;.") }</cr:message>
35                ),
36                $fail-nested := (
37                        for $pck in $packages[position() gt 1]
38                        return
39                                if ($pck[1]/UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq "stereotype"]/@value != ("Application Schema", "applicationSchema")) then ()
40                                else
41                                        <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>
42                )
43        return
44                if (empty($fail-root) and empty($fail-nested)) then ()
45                else
46                        <cr:fail>
47                                <cr:messages>{ $fail-root, $fail-nested }</cr:messages>
48                        </cr:fail>
49};
50
51(: Create a new result element :)
52mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/))
Note: See TracBrowser for help on using the repository browser.