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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/ISO19136-AnxE/test-013.xq@8406
Revision 8191, 2.7 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:    013
4Description:    Asserts all attribute and association target types are
5                                either internal, or external classes, or eaxmiid0 that
6                                corresponds to the NULL-type.
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
13import module namespace mod-xp = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:xmi-proc"
14at "#{ROOT_URL}ISO19136-AnxE/modules/module-xproc-functions.xq";
15
16declare namespace UML   = "omg.org/UML1.3";
17declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
18
19(: Declare local variables, particular to this test :)
20declare variable $test-num as xs:integer := 13;
21declare variable $pass-msg as xs:string := "Each class attribute and navigable association end resolves to a known class.";
22declare variable $fail-msg as xs:string := "The test has failed because:";
23
24(: Declare the local assert function which defines a postive condition for pass :)
25declare function local:assert($doc-root as node()?) as node()?
26{
27        let $elements := $doc-root//UML:Attribute/UML:StructuralFeature.type/UML:Classifier | $doc-root//UML:Association/UML:Association.connection/UML:AssociationEnd,
28                $fail := (
29                        for $el in $elements
30                                let $type := $el/string(@type | @xmi.idref),
31                                        $ancestor := $el/../..
32                                return
33                                        if ($type ne "eaxmiid0" and     (: corresponds to the NULL-type :)
34                                                empty($doc-root//UML:Class[@xmi.id eq $type]) and
35                                                empty($doc-root/XMI/XMI.extensions/EAStub[@UMLType eq "Class" and @xmi.id eq $type]))
36                                        then
37                                                <cr:message>
38                                                {
39                                                        if (local-name($ancestor) eq "Attribute") then
40                                                                concat("Class &quot;", $ancestor/../../@name, "&quot; attribute &quot;", $ancestor/@name, "&quot; does NOT have a known type.")
41                                                        else
42                                                        (
43                                                                let $owner := mod-xp:get-class-name-by-type($doc-root, ($el/preceding-sibling::UML:AssociationEnd | $el/following-sibling::UML:AssociationEnd)/@type)
44                                                                return concat("The association-end &quot;", (if (exists($el/@name)) then $el/@name else $el/@xmi.id), "&quot; on the association owned by &quot;", (if (exists($owner)) then $owner/@name else "&lt;&lt;Unknown&gt;&gt;"), "&quot; class does NOT have a known target class.")
45                                                        )
46                                                }
47                                                </cr:message>
48                                        else ()
49                )
50        return
51                if (empty($fail)) then ()
52                else
53                        <cr:fail>
54                                <cr:messages>{ $fail }</cr:messages>
55                        </cr:fail>
56};
57
58(: Create a new result element :)
59mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/))
Note: See TracBrowser for help on using the repository browser.