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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/ISO19136-AnxE/test-020.xq@8209
Revision 8191, 3.0 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:    020
4Description:    Asserts datatypes of tagged values.
5Reference:             
6~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:)
7
8import module namespace mod-fr = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:framework"
9at "#{ROOT_URL}ISO19136-AnxE/modules/module-framework-functions.xq";
10
11import module namespace mod-xp = "urn:local-module:ISO19136-V3.2-AnxE_XMI-V1.1:xmi-proc"
12at "#{ROOT_URL}ISO19136-AnxE/modules/module-xproc-functions.xq";
13
14declare namespace UML   = "omg.org/UML1.3";
15declare namespace cr    = "http://ndg.service.newmoon.conftest-result/1.0";
16
17(: Declare local variables, particular to this test :)
18declare variable $test-num as xs:integer := 20;
19declare variable $pass-msg as xs:string := "The value of every tagged value has the correct type.";
20declare variable $fail-msg as xs:string := "The value of certain tagged values have the incorrect type:";
21
22(:
23        #Date:          2008-12-02
24        #Author:        Pavel Golodoniuc
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                $fail := (
32                        (: typeof(noPropertyType,byValuePropertyType,isCollection,asDictionary,isMetadata)=xs:boolean :)
33                        for $tag in $doc-root//UML:TaggedValue[@tag = ("noPropertyType", "byValuePropertyType", "isCollection", "asDictionary", "isMetadata")]
34                        let $val := mod-xp:extract-value-from-tagval(string($tag/@value))
35                        where not(mod-xp:is-boolean($val))
36                        return <cr:message>{ concat("Tagged value ", $tag/@tag, "=&quot;", $val, "&quot; ", mod-xp:get-tag-owner-verbal($doc-root, $tag), " is not castable to xs:boolean. I.e. the value is not the correct type.") }</cr:message>,
37
38                        (: typeof(sequenceNumber)=xs:integer :)
39                        for $tag in $doc-root//UML:TaggedValue[@tag = ("sequenceNumber")]
40                        let $val := mod-xp:extract-value-from-tagval(string($tag/@value))
41                        where not(mod-xp:is-integer-positive($val))
42                        return <cr:message>{ concat("Tagged value ", $tag/@tag, "=&quot;", $val, "&quot; ", mod-xp:get-tag-owner-verbal($doc-root, $tag), " is not castable to xs:integer. I.e. the value is not the correct type.") }</cr:message>,
43
44                        (: typeof(inlineOrByReference)=enum(inline,byReference,inlineOrbyReference) :)
45                        for $tag in $doc-root//UML:TaggedValue[@tag eq "inlineOrByReference"]
46                        let $val := mod-xp:extract-value-from-tagval(string($tag/@value))
47                        where not(mod-xp:is-inlineOrByReference-tag-valid($val))
48                        return <cr:message>{ concat("Tagged value ", $tag/@tag, "=&quot;", $val, "&quot; ", mod-xp:get-tag-owner-verbal($doc-root, $tag), " is not a valid &quot;inlineOrByReference&quot; tag value. I.e. the value is not the correct type.") }</cr:message>
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.