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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/ISO19136-AnxE/test-006.xq@8406
Revision 8191, 3.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:    006
4Description:    Asserts unique and non-null values for all the
5                                "xsdDocument" tagged values on packages within the model.
6Reference:             
7
8#Update:        2009-08-11
9#Author:        Pavel Golodoniuc
10#Note:          Ported to eXist v1.2.x (production release).
11~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:)
12
13import module namespace mod-fr = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:framework"
14at "#{ROOT_URL}ISO19136-AnxE/modules/module-framework-functions.xq";
15
16import module namespace mod-xp = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:xmi-proc"
17at "#{ROOT_URL}ISO19136-AnxE/modules/module-xproc-functions.xq";
18
19declare namespace UML   = "omg.org/UML1.3";
20declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
21
22(: Declare local variables, particular to this test :)
23declare variable $test-num as xs:integer := 6;
24declare variable $pass-msg as xs:string := "The value of each "xsdDocument" tagged value is unique and syntactically correct.";
25declare variable $fail-msg as xs:string := "The Package is not serialized properly because:";
26
27(:
28        #Date:          2008-11-28
29        #Author:        Pavel Golodoniuc
30
31        Declare the local assert function which defines a postive condition for pass.
32:)
33declare function local:assert($doc-root as node()?) as node()?
34{
35        let $xsd-doc := $doc-root//UML:TaggedValue[@tag eq "xsdDocument"],
36                $fail-value := (
37                        (: Check that XSD document is correct for all xsdDocument tagged values :)
38                        for $el in $xsd-doc
39                        let $val := mod-xp:extract-value-from-tagval(string($el/@value))
40                        where not(mod-xp:is-xsdDocument-tag-valid($val))
41                        return <cr:message>{ concat("The tagged value xsdDocument=&quot;", $val, "&quot; on package &quot;", local:get-package-name($doc-root, $el), "&quot; is NOT a valid XSD Schema filename.") }</cr:message>
42                ),
43                $fail-dup := (
44                        (: Check that XSD document names are not duplicated :)
45                        for $dup in mod-xp:get-duplicates($xsd-doc/replace(@value, "^([^#]+)(&#35;.*)?$", "$1"))
46                        return
47                                let $filename := normalize-space($dup)
48                                for $el in $xsd-doc[starts-with(@value, $filename)]
49                                return <cr:message>{ concat("The tagged value xsdDocument=&quot;", $filename, "&quot; on package &quot;", local:get-package-name($doc-root, $el), "&quot; is NOT unique.") }</cr:message>
50                )
51        return
52                if (empty($fail-value) and empty($fail-dup)) then ()
53                else
54                        <cr:fail>
55                                <cr:messages>{ $fail-value, $fail-dup }</cr:messages>
56                        </cr:fail>
57};
58
59(:
60        #Date:          2008-11-28
61        #Author:        Pavel Golodoniuc
62
63        Resolves package name by xsdDocument tagged value.
64:)
65declare function local:get-package-name($doc-root as node()?, $xsd-doc as node()) as xs:string
66{
67        if ($xsd-doc/@modelElement) then
68                $doc-root//UML:Package[ends-with(@xmi.id, replace($xsd-doc/@modelElement, "^(.*)(.{36})$", "$2"))]/string(@name)
69        else
70                ($xsd-doc/ancestor::UML:Package)[1]/string(@name)
71};
72
73(: Create a new result element :)
74mod-fr:new-result($test-num, $pass-msg, $fail-msg, local:assert(/))
Note: See TracBrowser for help on using the repository browser.