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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/ISO19136-AnxE/test-011.xq@8406
Revision 8191, 4.1 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:    011
4Description:    Check that sequenceNumber tagged value is present on all
5                                attributes and association ends of class.
6Reference:   
7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:)
8
9import module namespace mod-fr = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:framework"
10at "#{ROOT_URL}ISO19136-AnxE/modules/module-framework-functions.xq";
11
12import module namespace mod-xp = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:xmi-proc"
13at "#{ROOT_URL}ISO19136-AnxE/modules/module-xproc-functions.xq";
14
15declare namespace UML   = "omg.org/UML1.3";
16declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
17
18(: Declare local variables, particular to this test :)
19declare variable $test-num as xs:integer := 11;
20declare variable $pass-msg as xs:string := "Each class attribute and navigable association-end does have a "sequenceNumber" tagged value.";
21declare variable $fail-msg as xs:string := "A "sequenceNumber" tagged-value is missing for:";
22
23(: Declare the local assert function which defines a postive condition for pass :)
24declare function local:assert($doc-root as node()?) as node()?
25{
26        let
27                (: Check presence of sequenceNumber tagged value for attributes :)
28                $attr-coll                      := $doc-root//UML:Attribute[../../UML:ModelElement.stereotype/UML:Stereotype/@name[matches(., "^(Type|FeatureType|DataType|type|featureType|dataType)$")]],
29                $attr-count                     := count($attr-coll),
30                $attr-count-seq         := count($attr-coll[UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq "sequenceNumber"]]),
31                $attr-fail                      := $attr-coll[empty(UML:ModelElement.taggedValue/UML:TaggedValue[@tag eq "sequenceNumber"])],
32                $attr-fail-error        := (
33                        (: Retrieve class name which attributes belong to :)
34                        for $attr in $attr-fail
35                        return <cr:message>{ concat("Class &quot;", $attr/../../@name, "&quot; attribute &quot;", $attr/@name, "&quot; does NOT have a &quot;sequenceNumber&quot; tagged-value.") }</cr:message>
36                ),
37
38                (: Check presence of sequenceNumber tagged value for association ends :)
39                $assoc-coll :=
40                        $doc-root//UML:Association//UML:AssociationEnd[
41                                .//UML:TaggedValue[@tag[matches(., "^(dest|source)style$")] and @value[contains(., "Navigable=Navigable;")]] or
42                                (
43                                        (:
44                                                When navigability of both association ends is unspecified
45                                                we must assume that both ends are navigable.
46                                        :)
47                                        .//UML:TaggedValue[@tag[matches(., "^(dest|source)style$")] and @value[contains(., "Navigable=Unspecified;")]] and
48                                        (preceding-sibling::* | following-sibling::*)[
49                                                .//UML:TaggedValue[@tag[matches(., "^(dest|source)style$")] and @value[contains(., "Navigable=Unspecified;")]]
50                                        ]
51                                )
52                        ],
53                $assoc-count            := count($assoc-coll),
54                $assoc-count-seq        := count($assoc-coll[.//UML:TaggedValue[@tag eq "sequenceNumber"]]),
55                $assoc-fail                     := $assoc-coll[empty(.//UML:TaggedValue[@tag eq "sequenceNumber"])],
56                $assoc-fail-error       := (
57                        (: Retrieve association xmi.id which association end belongs to :)
58                        for $assoc in $assoc-fail
59                        let $type1 := ($assoc/../UML:AssociationEnd)[1]/string(@type),
60                                $type2 := ($assoc/../UML:AssociationEnd)[2]/string(@type),
61                                $type1 := mod-xp:get-class-name-by-type($doc-root, $type1),
62                                $type2 := mod-xp:get-class-name-by-type($doc-root, $type2),
63                                $type1 := (if (exists($type1)) then $type1/@name else "&lt;&lt;Unknown&gt;&gt;"),
64                                $type2 := (if (exists($type2)) then $type2/@name else "&lt;&lt;Unknown&gt;&gt;")
65                        return <cr:message>{ concat("The navigable association-end &quot;", $assoc/@name, "&quot; between &quot;", $type1, "&quot; and &quot;", $type2, "&quot; classes does NOT have a &quot;sequenceNumber&quot; tagged-value.") }</cr:message>
66                )
67        return
68                if ($attr-count = $attr-count-seq and $assoc-count = $assoc-count-seq) then ()
69                else
70                        <cr:fail>
71                                <cr:messages>{ $attr-fail-error, $assoc-fail-error }</cr:messages>
72                        </cr:fail>
73};
74
75(: Create a new result element :)
76mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/))
Note: See TracBrowser for help on using the repository browser.